CSS练习-导航栏斜线分隔-利用伪元素_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:24:30
Original
1248 people have browsed it

开始切第一张图了,第一个遇到的问题是顶部导航栏这里,用斜线分割。想到的思路是用伪类:before或者:after实现

先写html结构。

<!-- 导航栏begin -->    <div class="header_right fr">    <a href="#" class="link">Home</a>    <a href="#" class="link">About</a>    <a href="#" class="link">Features</a>    <a href="#" class="link">Blog</a>    <a href="#" class="link">Shop</a>    <div class="alarm fr">    <img src="./images/alarm.png" alt="alarm" /></images><i class="alarm_number">2</i>    </div>    </div> <!-- 导航栏end -->
Copy after login

再是样式

.link:before{content: "/";margin:0 24px;color: grey;}.link:first-child:before{display:none;}
Copy after login

先用:bofore,设定内容是"/",前后margin,颜色。再用first-child将第一个元素之前的伪类去掉。

效果是这样的

似乎没有设计图里的斜线倾斜角度大呢……

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!