CSS

By admin, 12 二月, 2015

<div id="outer" style="width:100%">  
    <div id="inner">Foo foo</div>
</div>

方法一,需要制定里面DIV的宽度:
#inner {
    width: 50%;
    margin: 0 auto;
}

方法二:仅支持IE8+
#inner {
    display: table;
    margin: 0 auto;
}

标签

By admin, 12 二月, 2015

<style>
::-webkit-input-placeholder { /* WebKit browsers */
    color:    #909;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #909;
   opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    #909;
   opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
   color:    #909;
}
</style>

标签

By admin, 12 二月, 2015

<style>
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
</style>

<p>
  Selectable text.
</p>
<p class="noselect">
  Unselectable text.
</p>

标签

By admin, 6 二月, 2015

drupal_add_js和drupal_add_css已经不可用了。可以通过下面方法添加JS和CSS:

假设自定义的模块名称是foobar,在模块的目录下创建文件foobar.libraries.yml(模块的目录应该是modules/foobar),内容如下:

 

foobar:

  version: 1.x

    css:

      theme: css/foo.css: {}

    js: js/bar.js: {}

    dependencies: - core/jquery

然后在模块的目录下创建js/bar.js和css/foo.css就可以了。jquery不再是Drupal 8模块加载的JS,所以有需要就加上dependencies。

在return form的时候声明加载的库:

By admin, 4 二月, 2015
.canvas { background-color: #111; padding: 30px; clear: both; } #earth { width: 300px; height: 300px; background: url(http://www.noirextreme.com/digital/Earth-Color4096.jpg); border-radius: 50%; background-size: 610px; box-shadow: inset 8px 36px 80px 36px rgb(0, 0, 0), inset -6px 0 12px 4px rgba(255, 255, 255, 0.3); animation-name: rotate; animation-duration: 12s; animation-iteration-count: infinite; animation-timing-function: linear; -webkit-animation-name: rotate; -webkit-animation-duration: 12s; -webkit-anima