DIV+CSS里,我们用得最多的就是ul li来显示数据,如新闻按钮等。下面给大家一个css ul li的例子供学习

  

 [首页][15] 
  
 [博客][16] 
  
 [设计][17] 
  
 [相册][18] 
  
 [论坛][19] 
  
 [关于][20] 

  CSS:

   #menu ul {list-style:none;margin:0px;}

 #menu ul li {float:left;} 

  解释一下:

  #menu ul {list-style:none;margin:0px;}

  list-style:none,这一句是取消列表前点,因为我们不需要这些点。

  margin:0px,这一句是删除UL的缩进,这样做可以使所有的列表内容都不缩进。

  #menu ul li {float:left;}

  这里的 float:left 的左右是让内容都在同一行显示,因此使用了浮动属性(float)。

  CSS中的ul与li样式详解

  ul和li列表是使用CSS布局页面时常用的元素。在CSS中,有专门控制列表表现的属性,常用的有list-style-type属性、list-style-image属性、list-style-position属性和list-style属性。

  一、list-style-type属性

  list-style-type属性是用来定义li列表的项目符号的,即列表前面的修饰。list-style-type属性是一个可继承的属性。其语法结构如下:(列举一些常用的属性值)

  list-style-type:none/disc/circle/square/demical/lower-alpha/upper-alpha/lower-roman/upper-roman

  list-style-type属性的属性值有很多css 加号图标,在这里我们只是列举了比较常用的几个。

  none:不使用项目符号。 disc:实心圆。 circle:空心圆。 square:实心方块。 demical:阿拉伯数字。 lower-alpha:小写英文字母。 upper-alpha:大写英文字母。 lower-roman:小写罗马数字。 upper-roman:大写罗马数字。

  使用list-style-type属性的示例代码如下:

  li{

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  list-style-type:square;}

  该样式应用到页面的效果如下图所示:

  二、list-style-image属性

  list-style-image属性用来定义使用图片代替项目符号。它也是一个可继承属性,其语法结构如下:

  list-style-image:none/url

  list-style-image属性可以取两个值:

  none:没有替换的图片。 url:要替换图片的路径。

  来看一段代码:

  li{

  list-style-image:url(images/photo1.gif);}

  效果如下图。

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  三、list-style-position属性

  list-style-position属性,是用来定义项目符号在列表中显示位置的属性。它同样是一个可继承的属性,语法结构如下:

  list-style-position:inside/outside

  inside:项目符号放置在文本以内。 outside:项目符号放置在文本以外。

  使用list-style-position属性的示例如下:

  li{

  list-style-type:square;

  list-style-position:outside;}

  效果如下图所示。

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  再来看一下属性值为inside的样式。

  li{

  list-style-type:square;

  list-style-position:inside;}

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  四、list-style属性

  list-style属性是综合设置li样式的属性,也是一个可以继承的属性,语法结构如下:

  li-style:list-style-type/list-style-image/list-style-position

  各个值的位置可以交换。比如:

  li{

  list-style:url(images/bg03.gif) inside;}

  可以看一下应用到页面的效果。

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  以下开始主要介绍了纯CSS制作各种各样的网页图标(三角形、暂停按钮、下载箭头、加号等)的相关资料:

  三角形

  

 .box{
 width: 0;
 height: 0;
 border-top: 50px solid transparent;
 border-bottom: 50px solid transparent;
 border-left: 50px solid transparent;
 border-right: 50px solid red;
 }

  平行四边形图标

  

 .box{
 width: 50px;
 height: 50px;
 margin: 100px auto;
 background-color: red;
 transform: skew(-25deg);
} 

  汉堡按钮

  

 .box{
width: 50px;
height: 0px;
margin: 100px auto;
box-shadow: 36px 10px 0 3px red,
36px 0 0 3px red,
36px 20px 0 3px red;
  } 

  单选按钮

  因为box-shadow会按比例缩放css 加号图标,因此将第一个值设置为白色,然后将第二个值设置的比第一个值大就可以了

  

 .box{
width: 30px;
height: 30px;
margin: 100px auto;
background-color: #000;
border-radius: 50%;
box-shadow: 0 0 0 5px #fff,0 0 0 10px #000;
  } 

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  圆圈中带个十字

  

 .box {
width: 30px;
height: 30px;
margin: 100px auto;
background-color: #000;
border-radius: 50%;
box-shadow: 0 0 0 5px #fff, 0 0 0 10px #000;
outline: 36px solid #fff;
outline-offset: -50px;
  }

  需要在Chrome浏览器中打开,因为其他浏览器或许不支持

  田型图标

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  

 .box {
width: 0;
margin: 100px auto;
border: 3px solid red;
outline: 6px dotted red;
outline-offset: 6px;
  } 

  下载箭头

  使用border制作三角形,使用box-shadow制作正方形,主要用了偏移:

  

 .box {
width: 0;
margin: 100px auto;
color: red;
border: 8px solid transparent;
border-top: 8px solid red;
box-shadow: 0 -12px 0 -4px;
  } 

  书签

  实现这种效果的原理就是讲三角形设置成背景色,这样空心的三角形就出现了:

  

 .box {
width: 0;
height: 8px;
background-color:orange;
border: 8px solid transparent;
border-bottom: 8px solid #fff;
  } 

  两个半圆图标

  这个比较简单,就是通过渐变函数来实现,然后来个圆角边框:

  

 .box {
  width: 50px;
height: 50px;
border-radius: 50%;
background-image: linear-gradient(to right,#ccc 50%,#000 50%);
  }

  禁用图标

  外圈利用圆角边框,里面的竖线用渐变来做,然后再用旋转属性即可:

  

 .box {
  width: 50px;
height: 50px;
border-radius: 50%;
border:2px solid #000;
background: linear-gradient(to right,#fff  45%,#000 45%,#000 45%,#fff 55%);
transform: rotate(40deg);
  } 

  左右箭头图标

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  既然能做出一个三角形,那么就可以做出两个三角形。

  

 .box {
width: 0;
height: 0;
margin: 100px auto;
border: 10px solid transparent;
border-left: 10px solid red;
-webkit-box-reflect: left 5px;
box-reflect:left 5px;
  } 

  需要在Chrome浏览器中打开,因为其他浏览器或许不支持

  鹰嘴图标

  

 .box {
  width: 32px;
margin: 100px auto;
border-top: 50px solid transparent;
border-right: 22px solid #096;
border-bottom-right-radius: 100%;;
  } 

  需要在Chrome浏览器中打开,因为其他浏览器或许不支持

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  暂停按钮

  

 .box{
 width: 50px;
 height: 50px;
 margin: 100px auto;
 color: #000;
 border: 1px solid;
 border-radius: 50%;
 outline: 10px solid;
 outline-offset: -26px;
}

  加号

  

 .box{
width: 50px;
height: 50px;
margin: 100px auto;
color: #000;
border: 1px solid;
border-radius: 50%;
outline: 10px solid;
outline-offset: -35px;
  }

  如果再将其旋转,就变成了一个关闭按钮

  关闭按钮

  

 .box{
width: 50px;
height: 50px;
margin: 100px auto;
color: #000;
border: 1px solid;
border-radius: 50%;
outline: 10px solid;
outline-offset: -35px;
transform: rotate(45deg);
  }

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

  css 加号图标 学习CSS:解释一下cssulul的例子供学习li

TAGS:css css样式 css 加号图标 红色加号图标 css加号选择器 list-style
!如链接失效请在下方留言。本站所有资源均来源于网络,版权属于原作者!仅供学习参考,本站不对您的使用负任何责任。如果有侵权之处请第一时间联系我们删除,敬请谅解!