书写CSS时需要的七个方面指的是什么

今天就跟大家聊聊有关书写CSS时需要的七个方面指的是什么,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册网站空间、营销软件、网站建设、龙亭网站维护、网站推广。

书写CSS时注意的七个方面

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

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

◆不推荐使用行间样式

XML/HTML代码

                    Page title - book.chinaz.comtitle>     head>       <body>     <p style="color: red"> ... p>       body>       html></pre><p>◆不推荐使用内嵌样式</p><p>XML/HTML代码</p><pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en">       <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title>Page title - book.chinaz.comtitle>       <style type="text/css" media="screen">     p { color: red; }       style>       head>       <body>... body>       html></pre><p>◆推荐使用外联样式</p><p>XML/HTML代码</p><pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd">     <html lang="en">     <head>       <meta http-equiv="content-type" content="text       <title>Page title - book.chinaz.comtitle>       <link rel="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提出的所以老的浏览器不支持。</p><p>@import和link在使用上会有一些区别, 利用二者之间的差异,可以在实际运用中进行权衡。</p><p>关于@import和link方式的比较在52CSS.com上有几篇文章可以拓展阅读。</p><p>◆不推荐@import导入方式</p><p>XML/HTML代码</p><pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd">       <html lang="en">     <head>       <meta http-equiv="content-type" content="text       <title>Page title - 52css.comtitle>       <style type="text/css" media="screen">       @import url("styles.css");      style>     head>     <body> ... body>     html></pre><p>◆推荐引入外部样式表方式</p><p>XML/HTML代码</p><pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head>     <meta http-equiv="content-type" content="text       <title>Page title - blog.huangchao.orgtitle>     <link rel="stylesheet" href="name.css" type="text/css" media="screen" />     head>       <body> ... body>       html></pre><p><strong>三、使用继承</strong></p><p>低效率的</p><p>CSS代码</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; }</pre><p>高效的</p><p>CSS代码</p><pre>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>低效率的</p><p>CSS代码</p><pre>h2 { color: #236799; }       h3 { color: #236799; }      h4 { color: #236799; }      h5 { color: #236799; }</pre><p>高效的</p><p>CSS代码</p><pre>h2, h3, h4, h5 { color: #236799; }</pre><p><strong>五、使用多重声明</strong></p><p>低效率的</p><p>CSS代码</p><pre>p { margin: 0 0 1em; }      p { background: #ddd; }      p { color: #666; }</pre><p>译者注: 对于十六进制颜色值,个人偏向于色值不缩写且英文字母要大写的方式.</p><p>高效的</p><p>CSS代码</p><pre>p { margin: 0 0 1em; background: #ddd; color: #666; }</pre><p><strong>六、使用简记属性</strong></p><p>低效率的</p><p>CSS代码</p><pre>body { font-size: 85%; font-family: arial, helvetica, sans-serif; background-image: url(image.gif);   background-repeat: no-repeat; background-position: 0 100%; 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;</pre><p>高效的</p><p>CSS代码</p><pre>body { font: 85% arial, helvetica, sans-serif; background: url(image.gif) no-repeat 0 100%;   margin: 1em 1em 0; padding: 10px; border: 1px   solid red; color: #222; }</pre><p><strong> 七、避免使用 !important</strong></p><p>慎用写法</p><p>CSS代码</p><pre>#news { background: #ddd !important; }</pre><p>特定情况下可以使用以下方式提高权重级别</p><p>CSS代码</p><pre>#container #news { background: #ddd; }      body #container #news { background: #ddd; }</pre><p>看完上述内容,你们对书写CSS时需要的七个方面指的是什么有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。</p>            
            
                        <br>
            网页题目:书写CSS时需要的七个方面指的是什么            <br>
            URL链接:<a href="http://www.zjjierui.cn/article/iisdpo.html">http://www.zjjierui.cn/article/iisdpo.html</a>
        </div>
    </div>
    <div class="other">
        <h3>其他资讯</h3>
        <ul>
            <li>
                    <a href="/article/dicecdh.html">html5语句标签 html5所有标签的用法</a>
                </li><li>
                    <a href="/article/diceopp.html">变速箱电脑模拟故障(变速箱电脑模块故障)</a>
                </li><li>
                    <a href="/article/dicecdj.html">iOS自动订阅后端开发 ios订阅项目</a>
                </li><li>
                    <a href="/article/dicecse.html">台式电脑常见故障大全(台式机常见故障)</a>
                </li><li>
                    <a href="/article/dicedhp.html">台式电脑光驱打开故障(台式电脑光驱打开故障怎么回事)</a>
                </li>        </ul>
    </div>
</div>
<div class="f_service_con">
    <div class="h_fumin">
        <div class="h_fumin_lei">
            <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service01.png"></div>
            <p>售后响应及时</p><span>7×24小时客服热线</span>
        </div>
        <div class="h_fumin_lei">
            <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service02.png"></div>
            <p>数据备份</p><span>更安全、更高效、更稳定</span>
        </div>
        <div class="h_fumin_lei">
            <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service03.png"></div>
            <p>价格公道精准</p><span>项目经理精准报价不弄虚作假</span>
        </div>
        <div class="h_fumin_lei">
            <div class="h_fumin_lei_tu"><img src="/Public/Home/images/f_service04.png"></div>
            <p>合作无风险</p><span>重合同讲信誉,无效全额退款</span>
        </div>
    </div>
</div>
<div class="footerbar">
    <div class="footer-t">
        <div class="f-box">
            <div class="f-1">
                <div class="f-t">
                    <h2>联系我们</h2>
                    <span>TEL</span>
                </div>
                <div class="f-b">
                    <h1><a href="tel:13518219792" rel="nofollow">135-1821-9792</a></h1>
                    <h1><a href="tel:028-86922220" rel="nofollow">028-86922220</a></h1>
                    <p>地址:成都市太升南路288号锦天国际</p>

                </div>
            </div>
            <div class="f-2">
                <div class="f-t">
                    <h2>快捷导航</h2>
                    <span>Shortcut</span>
                </div>
                <div class="f-b">
                    <ul >
                    </ul>
                    <ul >
                        <li><a href="/jianshe" title="广元网站建设">广元网站建设</a></li>
                        <li><a href="/jianshe#ym_websiteBox2" title="品牌网站建设">品牌网站建设</a></li>
                        <li><a href="/jianshe#ym_websiteBox1" title="企业网站建设">企业网站建设</a></li>
                        <li><a href="/jianshe#ym_websiteBox4" title="集团网站建设">集团网站建设</a></li>
                        <li><a href="/jianshe#ym_websiteBox4_2" title="外贸网站建设">外贸网站建设</a></li>
                        <li><a href="/jianshe#ym_websiteBox4_5" title="企业宣传视频">企业宣传视频</a></li>
                    </ul>
                    <ul >
                        <li><a href="/weixin" title="微信开发">微信开发</a></li>
                        <li><a href="/weixin#item1" title="公众号开发">公众号开发</a></li>
                        <li><a href="/weixin#item2" title="微商城建设">微商城建设</a></li>
                        <li><a href="/weixin#item3" title="微官网建设">微官网建设</a></li>
                        <li><a href="/weixin#item4" title="小程序开发">小程序开发</a></li>
                    </ul>
                    <ul>
                        <li><a href="/case/" title="网站作品案例">网站作品案例</a></li>
                        <li><a href="/case/" title="品牌网站案例">品牌网站案例</a></li>
                        <li><a href="/case/" title="集团网站案例">集团网站案例</a></li>
                        <li><a href="/case/" title="企业网站案例">企业网站案例</a></li>
                        <li><a href="/case/" title="外贸网站案例">外贸网站案例</a></li>
                        <li><a href="/case/" title="营销网站案例">营销网站案例</a></li>
                    </ul>
                    <ul style="margin:0;">
                        <li><a href="/about/">广元建站</a></li>
                        <li><a href="/about/">公司简介</a></li>
                        <li><a href="/about#ab_item3">企业文化</a></li>
                        <li><a href="/contact">联系我们</a></li>
                        <li><a href="/Pay.html">付款方式</a></li>
                        <li><a href="/jianshe#ym_websiteBox8">售后服务</a></li>
                    </ul>
                    <div style="clear:both;"></div>
                </div>
            </div>
            <div class="f-3">
                <div class="f-t">
                    <h2>二维码</h2>
                    <span>QR CODE</span>
                </div>
                <div class="f-b">
                    <ul>
                        <li><img src="/Public/Home/images/fewm.png">
                            <p>微信公众号</p>
                        </li>
                        <li style="margin: 0"><img src="/Public/Home/images/fewm2.png">
                            <p>手机端网站</p>
                        </li>
                        <div style="clear:both;"></div>
                    </ul>
                </div>
            </div>
            <div style="clear:both;"></div>
        </div>
    </div>
    <div class="footer-about">
        <div class="w1200">广元优众联杰建站公司是一家专注从事于高品质视觉体验及互联网设计开发,<a href="/" target="_blank">广元网站建设</a>,<a
                href="/jianshe" target="_blank">广元网站设计</a>,<a href="/jianshe" target="_blank">广元网页设计</a>,<a
                href="/jianshe" target="_blank">广元网站制作</a>,<a href="/jianshe#ym_websiteBox2"
                                                              target="_blank">品牌网站建设</a>,<a href="/jianshe#ym_websiteBox3" target="_blank">营销网站建设</a>,<a
                href="/jianshe#ym_websiteBox4" target="_blank">集团网站建设</a>,<a href="/jianshe#ym_websiteBox1"
                                                                             target="_blank">企业网站建设</a>,<a href="/jianshe#ym_websiteBox4_2" target="_blank">外贸网站建设</a>,<a
                href="/jianshe#ym_websiteBox4_3" target="_blank">响应式网站建设</a>,<a href="/weixin#item4"
                                                                                target="_blank">小程序开发</a>,<a href="/weixin" target="_blank">微信开发</a>,<a
                href="/jianshe#ym_websiteBox4_4" target="_blank">企业形象设计</a>,<a href="/jianshe#ym_websiteBox4_5"
                                                                               target="_blank">企业宣传视频</a>等服务,优众联杰建站位于广元市龙岗区大运软件小镇,优众联杰建站拥有经验丰富的高级网站建设工程师和一流的网页高端设计人员,具备各种规模与类型网站建设的雄厚实力,在网站建设领域树立了自己独特的设计风格。
        </div>
        <div class="friend-links">
            <h6 class="clearfix">
                <span class="tilte">友情链接</span>
                <a class="exchagne" href="http://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes">交换友情链接</a>
            </h6>
            <div class="link-list clearfix">
                <div class="link-slider">
                    <a href="http://www.jinhuajc.com/" title="保温橡塑管" target="_blank">保温橡塑管</a>   <a href="https://www.cdxwcx.com/jifang/ershu.html" title="中国电信成都枢纽中心" target="_blank">中国电信成都枢纽中心</a>   <a href="http://www.yuzhoubg.com/" title="成都楼顶广告牌" target="_blank">成都楼顶广告牌</a>   <a href="http://www.xiwangwangguoyuan.com/" title="德阳网站运维" target="_blank">德阳网站运维</a>   <a href="http://chengdu.cdcxhl.cn/jianshe/
" title="品牌网站建设" target="_blank">品牌网站建设</a>   <a href="http://www.wjwzjz.com/" title="温江网站制作" target="_blank">温江网站制作</a>   <a href="https://www.cdxwcx.com/city/dujiangyan/" title="都江堰做网站" target="_blank">都江堰做网站</a>   <a href="http://m.cdcxhl.com/liucheng.html" title="成都网站建设流程" target="_blank">成都网站建设流程</a>   <a href="http://www.huixingan.com/" title="huixingan.com" target="_blank">huixingan.com</a>   <a href="http://www.cdxwcx.cn/tuoguan/xibuxinxi.html" title="中国电信西部信息中心机房" target="_blank">中国电信西部信息中心机房</a>                   </div>
            </div>
        </div>
    </div>
    <div class="footer-b">
        <div class="f-box">
            <ul>
                <li><a href="/jianshe#ym_websiteBox6" target="_blank">服务流程</a></li>
                <li><a href="/jianshe#ym_websiteBox8" target="_blank">售后服务</a></li>
                <li><a href="/about/" target="_blank">联系我们</a></li>
                <li><a href="https://www.cdxwcx.com/pay/" target="_blank">付款方式</a></li>
                <li><a href="https://www.cdcxhl.com/menu.html" target="_blank">网站地图</a></li>
                <li><a href="#" target="_blank">sitemap</a></li>
                <li>
                    <p>
                        <script data-cfasync="false" src="/Public/Home/js/email-decode.min.js"></script>
                    </p>
                </li>
                <div style="clear:both;"></div>
            </ul>
            <p class="copy">Copyright © 2025 成都优众联杰科技有限公司 广元建站公司 All Rights Reserved   <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2024116266号-5</a>
                <a style="display:none" target="_blank" href="###"><img style="vertical-align:middle" border="0" src="" width="65" height="25" /></a>

            </p>
            <div style="clear:both;"></div>
        </div>
    </div>
    <div class="sj_footer">
        <div class="f-box">
            <ul>
                <li><a href="/jianshe" target="_blank">网站建设</a></li>
                <li><a href="/jianshe#ym_websiteBox6" target="_blank">服务流程</a></li>
                <li><a href="/jianshe#ym_websiteBox8" target="_blank">售后服务</a></li>
                <li><a href="https://www.cdxwcx.com/pay/" target="_blank">付款方式</a></li>
                <li><a href="/about/" target="_blank">关于我们</a></li>
                <li><a href="https://www.cdcxhl.com/menu.html" target="_blank">网站地图</a></li>
                <div style="clear:both;"></div>
            </ul>
            <p class="copy">Copyright © 2025 成都优众联杰科技有限公司 广元建站公司 </p>
            <p class="copy"> <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2024116266号-5</a>  <a
                    href="###" target="_blank"><img src="/Public/Home/images/govicon.gif" width="20" height="28" border="0" style="border-width:0px;border:hidden; border:none;"></a></p>
            <div style="clear:both;"></div>
        </div>
    </div>
</div>
<script type='text/javascript' src='/Public/Home/js/qqkefu.js'></script>
<div class="qqkefu">
    <ul>
        <li class="qq_czaa" id="130"><b class="a"></b>135-1821-9792</li>
        <li class="qq_czaa" id="130"><a href="tencent://message/?uin=1683211881"><b class="b"></b>业务咨询QQ</a></li>
        <li class="qq_czaa" id="130"><a href="javascript:showDiv()"><b class="f"></b>提交合作意向表</a></li>
        <li class="qq_czb">
            <b class="c"></b>
            <div class="erweima">
                <p><img src="/Public/Home/images/right_erweima.png"></p>
            </div>
        </li>
        <li class="top"><span></span></li>
    </ul>
</div>
<div id="popDiv" class="mydiv" style="display:none;">
    <a class="mydiv_clk" href="javascript:closeDiv()">X</a>
    <div class="mydiv_list">
        <div class="c_f_title"><span class="c_f_t">合作意向表</span></div>
        <div class="c_f_con">
            <form id="form1" name="form1" class="mess_form" method="post" action="/post_order">
                <input name='enews' type='hidden' value='AddFeedback'>
                <input name="bid" value="1" type="hidden">
                <input type="hidden" name="ecmsfrom" value="9">
                <input type="hidden" name='title' value="客户提交需求">
                <li class="c_n"><span>公司名称</span>
                    <dl><input name='gsname' id='gsname' type="text"></dl>
                </li>
                <li class="c_n"><span>邮箱</span>
                    <dl><input name='gemail' id='gemail' type="text"></dl>
                </li>
                <li class="c_n xmm">
                    <div class="xmm_01"><span>姓名</span>
                        <dl class="c_n_i"><input name='name' id='name' type="text"></dl>
                    </div>
                    <div class="xmm_01"><span style="text-align:center">电话</span>
                        <dl class="c_n_i"><input name="tel" type="text"></dl>
                    </div>
                </li>
                <li class="c_tser">您需要的服务</li>
                <li class="clearfix">
                    <dd><label><input type="radio" name='hobby' id='hobby' value="高端网站建设"><span>高端网站建设</span></label></dd>
                    <dd><label><input type="radio" name='hobby' id='hobby' value="我需要做微信营销"><span>我需要做微信营销</span></label></dd>
                    <dd><label><input type="radio" name='hobby' id='hobby' value="要找长期合作,需要年度服务"><span>要找长期合作,需要年度服务</span></label></dd>
                    <dd><label><input type="radio" name='hobby' id='hobby' value="我需要做购物商城"><span>我需要做购物商城</span></label></dd>
                    <dd><label><input type="radio" name='hobby' id='hobby' value="我需要网站改版"><span>我需要网站改版</span></label></dd>
                    <dd><label><input type="radio" name='hobby' id='hobby' value="其他"><span>其他</span></label></dd>
                </li>
                <li class="c_tser">您关注的地方</li>
                <li class="clearfix">
                    <dd><label><input type="radio" name='hobby2' id='hobby2' value="对功能要求比较高"><span>对功能要求比较高</span></label></dd>
                    <dd><label><input type="radio" name='hobby2' id='hobby2' value="对设计创意要求比较高"><span>对设计创意要求比较高</span></label></dd>
                    <dd><label><input type="radio" name='hobby2' id='hobby2' value="需要可以购物支付"><span>需要可以购物支付</span></label></dd>
                    <dd><label><input type="radio" name='hobby2' id='hobby2' value="搜索引擎排名"><span>搜索引擎排名</span></label></dd>
                </li>
                <li class="c_tser">预算</li>
                <li class="clearfix clearfix2">
                    <dd><label><input type="radio" name='hobby3' id='hobby3' value="一万以内"><span>一万以内</span></label>
                    </dd>
                    <dd><label><input type="radio" name='hobby3' id='hobby3' value="1-3万"><span>1-3万</span></label>
                    </dd>
                    <dd><label><input type="radio" name='hobby3' id='hobby3' value="3-5万"><span>3-5万</span></label>
                    </dd>
                    <dd><label><input type="radio" name='hobby3' id='hobby3' value="5万以上"><span>5万以上</span></label>
                    </dd>
                    <dd><label><input type="radio" name='hobby3' id='hobby3' value="需招投标"><span>需招投标</span></label>
                    </dd>
                </li>
                <li class="c_n" style="border-top:1px solid #eee; padding-top:10px"><span>验证码</span>
                    <dl class="c_n_i yzmm"><input type="text" name='code' id='code' value=""></dl><span
                            style="text-align:center"><img src="/Public/Home/images/1661eb19783442c38063791555cd0d80.gif"
                                                           onclick="this.src=this.src + '?'" width="100" height="40"></span>
                </li>
                <li class="clearfix">
                    <dd class="submit"><input name='submit' type="submit" value="提交需求"></dd>
                </li>
            </form>
        </div>
    </div>
</div>
<div id="bg" class="bg" style="display:none;"></div>
<div id='popIframe' class='popIframe' frameborder='0'></div>
<script>
    //提交需求选项
    $(document).ready(function (e) {
        $(".mess_form").submit(function () {
            if ($("#gsname").val() == "") {
                alert("请填写您的公司名称!");
                $("#gsname").focus();
                return false;
            }
            if ($("#gemail").val() == "") {
                alert("请填写您的邮箱");
                $("#gemail").focus();
                return false;
            }
            if ($("#name").val() == "") {
                alert("请填写您的姓名!");
                $("#name").focus();
                return false;
            }
            if ($("#tel").val() == "") {
                alert("请填写您的电话!");
                $("#tel").focus();
                return false;
            }
            if ($("#hobby").val() == "") {
                alert("请选择您需要的服务!");
                $("#hobby").focus();
                return false;
            }
            if ($("#hobby2").val() == "") {
                alert("请选择您关注的地方!");
                $("#hobby2").focus();
                return false;
            }
            if ($("#hobby3").val() == "") {
                alert("请选择您的预算!");
                $("#hobby3").focus();
                return false;
            }
            if ($("#code").val() == "") {
                alert("请填写正确的验证码!");
                $("#code").focus();
                return false;
            }
        });
    });
</script>
<script language="javascript" type="text/javascript">
    //提交需求窗口
    function showDiv() {
        document.getElementById('popDiv').style.display = 'block';
        document.getElementById('popIframe').style.display = 'block';
        document.getElementById('bg').style.display = 'block';
    }
    function closeDiv() {
        document.getElementById('popDiv').style.display = 'none';
        document.getElementById('bg').style.display = 'none';
        document.getElementById('popIframe').style.display = 'none';
    }
</script>
<script type="text/javascript" src="/Public/Home/js/scrolltopcontrol.js"></script>
<script type="text/javascript" src="/Public/Home/js/su_new.js"></script>
</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>