Home > Web Front-end > HTML Tutorial > div ul li Basic questions for beginners. There are pictures and codes. Experts can take a look. Thank you._html/css_WEB-ITnose

div ul li Basic questions for beginners. There are pictures and codes. Experts can take a look. Thank you._html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:01:33
Original
1187 people have browsed it




    
    
.header-nav {margin: 0 auto; margin:3px 3px ; border: thin solid red;    }
 .header-nav ul {   width:99%; margin:3px 3px ; border: thin solid  black; } 
 .header-nav li { float: left; width:13%;   list-style-type: none; 
                margin:3px 3px ; border: thin solid orange;  }
    


 
    


                 
  • 首页

  •              
  • 品牌中心
  •     
                
  • 专家团队

  •        

    




回复讨论(解决方案)

如果li float了之后,会影响兄弟,父级元素。所以必须使用clear来清除。
demo here

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">        .header-nav {margin: 0 auto; margin:3px 3px ; border: thin solid red;    }        .header-nav ul { width:99%; margin:3px 3px ; border: thin solid  black; }        .header-nav li { float: left; width:13%; list-style-type: none;margin:3px 3px ; border: thin solid orange;  }        .clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}        .clearfix{display:inline-block;}        html[xmlns] .clearfix{display:block;}        * html .clearfix{height:1%;}    </style></head><body><div class="header-nav">    <ul class="clearfix">        <li><a href="">首页</a></li>        <li><a href="" target="_blank">品牌中心</a></li>        <li><a href="" target="_blank">专家团队</a></li>    </ul></div></body></html>
Copy after login
Copy after login

如果li float了之后,会影响兄弟,父级元素。所以必须使用clear来清除。
demo here

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">        .header-nav {margin: 0 auto; margin:3px 3px ; border: thin solid red;    }        .header-nav ul { width:99%; margin:3px 3px ; border: thin solid  black; }        .header-nav li { float: left; width:13%; list-style-type: none;margin:3px 3px ; border: thin solid orange;  }        .clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}        .clearfix{display:inline-block;}        html[xmlns] .clearfix{display:block;}        * html .clearfix{height:1%;}    </style></head><body><div class="header-nav">    <ul class="clearfix">        <li><a href="">首页</a></li>        <li><a href="" target="_blank">品牌中心</a></li>        <li><a href="" target="_blank">专家团队</a></li>    </ul></div></body></html>
Copy after login
Copy after login



那after  是什么 意思
.clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}       

 .clearfix{display:inline-block;}    
    html[xmlns] .clearfix{display:block;}      
  * html .clearfix{height:1%;} 这个又是什么意思 
老大,我是菜鸟能不能解释细点,或弄简单点

而且 我用了,没效果啊,还是没变化 

有效果 ,但那个ul还是超出了div 它不是在div里面吗,怎么超出去了


如果li float了之后,会影响兄弟,父级元素。所以必须使用clear来清除。
demo here

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">       *{margin:0;padding:0;}        .header-nav {margin: 0 auto; margin:3px 3px ; border: thin solid red;    }        .header-nav ul { width:99%; margin:3px 3px ; border: thin solid  black; }        .header-nav li { float: left; width:13%; list-style-type: none;margin:3px 3px ; border: thin solid orange;  }        .clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}        .clearfix{display:inline-block;}        html[xmlns] .clearfix{display:block;}        * html .clearfix{height:1%;}    </style></head><body><div class="header-nav">    <ul class="clearfix">        <li><a href="">首页</a></li>        <li><a href="" target="_blank">品牌中心</a></li>        <li><a href="" target="_blank">专家团队</a></li>    </ul></div></body></html>
Copy after login



那after  是什么 意思
.clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}       

 .clearfix{display:inline-block;}    
    html[xmlns] .clearfix{display:block;}      
  * html .clearfix{height:1%;} 这个又是什么意思 
老大,我是菜鸟能不能解释细点,或弄简单点


关于clearfix
个人建议问百度或许比较更全面清楚一点, http://www.baidu.com/s?wd=clearfix&rsv_bp=0&tn=baidu&rsv_spt=3&ie=utf-8&rsv_sug3=1&rsv_sug4=42&rsv_sug1=1&rsv_sug2=0&inputT=1028
超出去的原因,没有重置css。
什么是重置css
*{margin:0;padding:0;}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template