网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

几个超级实用的css代码片段

1、伸展一个元素到窗口高度

创新互联公司专业为企业提供华宁网站建设、华宁做网站、华宁网站设计、华宁网站制作等企业网站建设、网页设计与制作、华宁企业网站模板建站服务,十年华宁做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

 在具体场景中,你可能想要将一个元素伸展到窗口高度,基本元素的调整只能调整容器的大小,因此要使一个元素伸展到窗口高度,我们需要伸展顶层元素:html和body:

html, 

body {

    height: 100%;

}

 然后将100%应用到任何元素的高:

div {

    height: 100%;

}

2、只在一边或两边显示盒子阴影

 如果你要一个盒阴影,试试这个技巧,能为任一边添加阴影。为了实现这个,首先定义一个有具体宽高的盒子,然后正确定位:after伪类。实现底边阴影的代码如下:

.box-shadow {

    background-color: #FF8020;

    width: 160px;

    height: 90px;

    margin-top: -45px;

    margin-left: -80px;

    position: absolute;

    top: 50%;

    left: 50%;

}

.box-shadow:after {

    content: "";

    width: 150px;

    height: 1px;

    margin-top: 88px;

    margin-left: -75px;

    display: block;

    position: absolute;

    left: 50%;

    z-index: -1;

    -webkit-box-shadow: 0px 0px 8px 2px #000000;

       -moz-box-shadow: 0px 0px 8px 2px #000000;

            box-shadow: 0px 0px 8px 2px #000000;

}

3、制造模糊文本

 想要让文本模糊?可以使用color透明和text-shadow实现。

.blurry-text {

   color: transparent;

   text-shadow: 0 0 5px rgba(0,0,0,0.5);

}

3、新版清除浮动(2011)

.clearfix:before, .container:after { content: ""; display: table; }

.clearfix:after { clear: both; }

/* IE 6/7 */

.clearfix { zoom: 1; }

4、通用媒体查询

/* Smartphones (portrait and landscape) ----------- */

@media only screen 

and (min-device-width : 320px) and (max-device-width : 480px) {

  /* Styles */

}

/* Smartphones (landscape) ----------- */

@media only screen and (min-width : 321px) {

  /* Styles */

}

/* Smartphones (portrait) ----------- */

@media only screen and (max-width : 320px) {

  /* Styles */

}

/* iPads (portrait and landscape) ----------- */

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {

  /* Styles */

}

/* iPads (landscape) ----------- */

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {

  /* Styles */

}

/* iPads (portrait) ----------- */

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {

  /* Styles */

}

/* Desktops and laptops ----------- */

@media only screen and (min-width : 1224px) {

  /* Styles */

}

/* Large screens ----------- */

@media only screen and (min-width : 1824px) {

  /* Styles */

}

/* iPhone 4 ----------- */

@media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {

  /* Styles */

}

5、强制出现垂直滚动条

html { height: 101% }

6、CSS3 斑马线

tbody tr:nth-child(odd) {

    background-color: #ccc;

}


网页标题:几个超级实用的css代码片段
链接URL:http://bjjierui.cn/article/gphocs.html

其他资讯