书写高效CSS注意的七个方面分别是什么-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

书写高效CSS注意的七个方面分别是什么

这期内容当中小编将会给大家带来有关书写高效CSS注意的七个方面分别是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

创新互联公司致力于互联网品牌建设与网络营销,包括成都网站制作、成都网站设计、SEO优化、网络推广、整站优化营销策划推广、电子商务、移动互联网营销等。创新互联公司为不同类型的客户提供良好的互联网应用定制及解决方案,创新互联公司核心团队十多年专注互联网开发,积累了丰富的网站经验,为广大企业客户提供一站式企业网站建设服务,在网站建设行业内树立了良好口碑。

你对如何书写高效CSS是否熟悉,这里和大家分享一下书写高效CSS注意的七个方面,主要包括使用外联样式替代行间样式或者内嵌样式,建议使用link引入外部样式表等内容。

CSS经验分享:书写高效CSS注意的七个方面

随着CSS网页布局的应用越来越广泛,更多的CSSer开始书写CSS,如何才能写出高效规范的CSS代码呢,本文向大家介绍一下必须要注意的七个方面:

一、使用外联样式替代行间样式或者内嵌样式

不推荐使用行间样式

ExampleSourceCode

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    Pagetitle-52css.comtitle> head> <body> <pstylepstyle="color:red">...p> body> html></pre><p>不推荐使用内嵌样式</p><p>ExampleSourceCode</p><pre>"http://www.w3.org/TR/html4/strict.dtd"><htmllanghtmllang="en"> <head> <metahttp-equivmetahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> <title>Pagetitle-52css.comtitle> <styletypestyletype="text/css"media="screen"> p{color:red;}  style> head> <body>...body> html></pre><p>推荐使用外联样式</p><p>ExampleSourceCode</p><pre>"http://www.w3.org/TR/html4/strict.dtd"> <htmllanghtmllang="en"> <head> <metahttp-equivmetahttp-equiv="content-type"content="text  <title>Pagetitle-52css.comtitle> <linkrellinkrel="stylesheet"href="name.css"type="text/css"media="screen"/> head> <body>...body> html></pre><p><strong>二、建议使用link引入外部样式表</strong></p><p>为了兼容老版本的浏览器,建议使用link引入外部样式表的方来代替@import导入样式的方式.</p><p>译者注:@import是CSS2.1提出的所以老的浏览器不支持,点击查看@import的兼容性。</p><p>@import和link在使用上会有一些区别,利用二者之间的差异,可以在实际运用中进行权衡。</p><p>关于@import和link方式的比较在52CSS.com上有几篇文章可以拓展阅读。</p><p>不推荐@import导入方式</p><p>ExampleSourceCode</p><pre> "http://www.w3.org/TR/html4/strict.dtd"> <htmllanghtmllang="en"> <head> <metahttp-equivmetahttp-equiv="content-type"content="text  <title>Pagetitle-52css.comtitle> <styletypestyletype="text/css"media="screen"> @importurl("styles.css");  style> head> <body>...body> html></pre><p>推荐引入外部样式表方式</p><p>ExampleSourceCode</p><pre>"http://www.w3.org/TR/html4/strict.dtd"><htmllanghtmllang="en"><head> <metahttp-equivmetahttp-equiv="content-type"content="text  <title>Pagetitle-52css.comtitle> <linkrellinkrel="stylesheet"href="name.css"type="text/css"media="screen"/> head> <body>...body> html></pre><p><strong>三、使用继承</strong></p><p>ExampleSourceCode</p><pre>低效率的   p{font-family:arial,helvetica,sans-serif;}  #container{font-family:arial,helvetica,sans-serif;}  #navigation{font-family:arial,helvetica,sans-serif;}  #content{font-family:arial,helvetica,sans-serif;}  #sidebar{font-family:arial,helvetica,sans-serif;}  h2{font-family:georgia,times,serif;}   高效的   body{font-family:arial,helvetica,sans-serif;}  body{font-family:arial,helvetica,sans-serif;}  h2{font-family:georgia,times,serif;}</pre><p><strong>四、使用多重选择器</strong></p><p>ExampleSourceCode</p><pre>低效率的   h2{color:#236799;}  h3{color:#236799;}  h4{color:#236799;}  h5{color:#236799;}   高效的   h2,h3,h4,h5{color:#236799;}</pre><p><strong>五、使用多重声明</strong></p><p>ExampleSourceCode</p><pre>低效率的   p{margin:001em;}  p{background:#ddd;}  p{color:#666;}   译者注:对于十六进制颜色值,个人偏向于色值不缩写且英文字母要大写的方式.   高效的   p{margin:001em;background:#ddd;color:#666;}</pre><p><strong>六、使用简记属性</strong></p><p>ExampleSourceCode</p><pre>低效率的   body{font-size:85%;font-family:arial,helvetica,sans-serif;  background-image:url(image.gif);background-repeat:no-repeat;  background-position:0100%;margin-top:1em;margin-right:1em;  margin-bottom:0;margin-left:1em;padding-top:10px;  padding-right:10px;padding-bottom:10px;padding-left:10px;  border-style:solid;border-width:1px;border-color:red;color:#222222;   高效的   body{font:85%arial,helvetica,sans-serif;  background:url(image.gif)no-repeat0100%;margin:1em1em0;  padding:10px;border:1pxsolidred;color:#222;}</pre><p><strong>七、避免使用!important</strong></p><p>ExampleSourceCode</p><pre>慎用写法   #news{background:#ddd!important;}  特定情况下可以使用以下方式提高权重级别  #container#news{background:#ddd;}  body#container#news{background:#ddd;}</pre><p>上述就是小编为大家分享的书写高效CSS注意的七个方面分别是什么了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。</p>            
            
                        <br>
            分享题目:书写高效CSS注意的七个方面分别是什么            <br>
            URL链接:<a href="http://kswsj.cn/article/jojsdg.html">http://kswsj.cn/article/jojsdg.html</a>
        </div>
    </div>
    <div class="other">
        <h3>其他资讯</h3>
        <ul>
            <li>
                    <a href="/article/dscshss.html">vb.net标准版,vbnet vb区别</a>
                </li><li>
                    <a href="/article/dscsphg.html">mysql每个字段怎么查,mysql字段查询</a>
                </li><li>
                    <a href="/article/dscshcd.html">c语言快排函数,快排实现 c</a>
                </li><li>
                    <a href="/article/dscshse.html">珠海flutter开发,flutter 项目</a>
                </li><li>
                    <a href="/article/dscspjh.html">cvb.net的简单介绍</a>
                </li>        </ul>
    </div>
</div>
<div class="line"></div>
<!--底部-->
<footer id="5">
    <div class="foot1 container">
        <div class="list">
            <div class="item">
                <a href="javascript:;">
                    <span class="ico1"><i class="iconfont"></i><img src="/Public/Home/img/ewm.png" alt=""></span>
                    <strong>关注我们</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>索要报价</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>我要咨询</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>找到我们</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>投诉建议</strong>
                </a>
            </div>
        </div>
        <div class="tel">
            <dl>
                <tel><a href="tel:400-028-6601" target="_blank">400-028-6601</a></tel><br>
                <span>也许您需要专业的服务,欢迎来电咨询</span>
            </dl>
            <dl>
                <tel><a href="tel:18980820575" target="_blank">18980820575</a></tel><br>
                <span>您的需求,是我们前进的动力</span>
            </dl>
        </div>
    </div>
    <div class="friend">
        <div class="container">
            <span class="tit">友情链接:</span>
            <div class="inner">
                <a href="https://www.cdcxhl.com/shoulu/" target="_blank">分类目录</a><a href="https://www.cdcxhl.com/link/" target="_blank">友情链接出售</a><a href="https://www.cdcxhl.com/shop.html" target="_blank">商城网站开发</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">软文营销</a><a href="https://www.cdcxhl.com/waimao.html" target="_blank">成都外贸网站建设公司</a><a href="https://www.cdcxhl.com/zuyong/" target="_blank">成都租用服务器</a><a href="https://www.cdcxhl.com/yingxiao.html" target="_blank">成都营销型网站建设</a><a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">小程序开发公司</a><a href="https://www.cdcxhl.com/seo.html" target="_blank">成都网站推广</a><a href="https://www.cdcxhl.com/google.html" target="_blank">谷歌推广</a><a href="https://www.cdcxhl.com/" target="_blank">建站公司</a><a href="https://www.cdcxhl.com/gaiban/" target="_blank">网站改版公司</a><a href="https://www.cdcxhl.com/" target="_blank">成都网站制作</a><a href="https://www.cdcxhl.com/pinpai.html" target="_blank">成都品牌网站建设</a><a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">微信小程序开发公司</a><a href="https://www.cdcxhl.com/shoulu/" target="_blank">网站收录</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">软文推广营销</a><a href="https://www.cdcxhl.com/tuoguan/yaan/" target="_blank">川西大数据中心</a>            </div>
        </div>
    </div>
    <div class="foot">
        <div class="container">
            <div class="footNav">
                <h3>网站建设</h3>
                <a href="https://www.cdxwcx.com/" target="_blank">成都网站建设</a><a href="https://www.cdxwcx.com/city/qionglai/" target="_blank">邛崃网站建设</a><a href="http://www.cdkjz.cn/" target="_blank">成都网站建设</a>            </div>
            <div class="footNav">
                <h3>服务器托管</h3>
                <a href="https://www.cdcxhl.com/jigui/" target="_blank">服务器机柜租赁</a><a href="https://www.cdcxhl.com/idc/wenjiang.html" target="_blank">温江服务器托管</a><a href="https://www.cdcxhl.com/jigui/" target="_blank">服务器机柜租用</a>            </div>
            <div class="footNav">
                <h3>网站制作</h3>
                <a href="http://m.cdcxhl.com/" target="_blank">成都网站制作</a><a href="http://www.cdxwcx.cn/bj/" target="_blank">网站制作价格</a><a href="http://www.kswsj.com/" target="_blank">成都网站制作</a>            </div>
            <div class="footNav">
                <h3>企业服务</h3>
                <a href="https://www.cdcxhl.com/service/zzgj.html" target="_blank">备案资质管家服务</a><a href="https://www.cdcxhl.com/ruanwen/yingxiao/" target="_blank">软文营销</a><a href="https://www.cdcxhl.com/service/beian.html" target="_blank">网站备案</a>            </div>
            <div class="fr ecode">
                <div class="fl">
                    <img src="/Public/Home/img/ewm.jpg">
                    <p>关注企业微信</p>
                </div>
                <div class="fr slogan">
                    <p class="icon">
                        <a class="ph" href=""><i class="iconfont"></i></a>
                        <a class="qq" href="tencent://message/?uin=1683211881&Site=&Menu=yes"><i class="iconfont"></i></a>
                    </p>
                    <p>
                        <i>想要找 </i> <a href="">小程序开发</a>、<a href="">APP开发</a>、
                        <a href="">营销型网站建设</a>、<a href="">网站建设</a>、
                        <i><a href="">网站定制开发</a></i> ,就选<a href="">创新互联</a>
                    </p>
                </div>
            </div>
        </div>
        <div class="bottom container">
            <p class="fl">
                版权所有:成都创新互联科技有限公司
                备案号:<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备19037934号</a>
                服务热线:028-86922220
            </p>
            <p class="fr">
                <a href="https://www.cdxwcx.com/" target="_blank">成都网站建设</a>:
                <a href="https://www.cdcxhl.com/" target="_blank">创新互联</a>
            </p>
        </div>
    </div>
</footer>
<!--在线咨询-->
<div class="fot">
    <ul>
        <li>
            <a href="https://p.qiao.baidu.com/cps/mobileChat?siteId=11284691&userId=6256368&type=1&reqParam=%20{%22from%22:0,%22sessionid%22:%22%22,%22siteId%22:%2211284691%22,%22tid%22:%22-1%22,%22userId%22:%226256368%22,%22ttype%22:1,%22siteConfig%22:%20{%22eid%22:%226256368%22,%22queuing%22:%22%22,%22siteToken%22:%226ce441ff9e2d6bedbdfc2a4138de449e%22,%22userId%22:%226256368%22,%22isGray%22:%22false%22,%22wsUrl%22:%22wss://p.qiao.baidu.com/cps3/websocket%22,%22likeVersion%22:%22generic%22,%22siteId%22:%2211284691%22,%22online%22:%22true%22,%22webRoot%22:%22//p.qiao.baidu.com/cps3/%22,%22bid%22:%22160142915792139572%22,%22isSmallFlow%22:0,%22isPreonline%22:0,%22invited%22:0%20},%22config%22:%20{%22themeColor%22:%224d74fa%22%20}%20}&appId=&referer=&iswechat=0&expectWaiter=-1&openid=null&otherParam=null&telephone=null&speedLogId=null&eid=null&siteToken=6ce441ff9e2d6bedbdfc2a4138de449e" target="_blank">
                <img src="/Public/Home/img/fot1.png" alt="">
                <p>在线咨询</p>
            </a>
        </li>
        <li>
            <a href="tel:18980820575" target="_blank">
                <img src="/Public/Home/img/fot2.png" alt="">
                <p>拨打电话</p>
            </a>
        </li>
    </ul>
</div>
</body>
</html>
<script>
    $(".con img").each(function(){
        var src = $(this).attr("src");    //获取图片地址
        var str=new RegExp("http");
        var result=str.test(src);
        if(result==false){
            var url = "https://www.cdcxhl.com"+src;    //绝对路径
            $(this).attr("src",url);
        }
    });
    window.onload=function(){
        document.oncontextmenu=function(){
            return false;
        }
    }
</script>