• 技术文章 >web前端 >css教程

    dedecms怎么修改css

    anonymityanonymity2019-05-28 09:49:58原创2702
    织梦DedeCMS修改模板默认CSS文件分析:首先,打开后台——模板——默认模板管理——index.htm.

    看到有一句,<link href="{dede:global.cfg_templeturl/}/style/dedecms.css" rel="stylesheet" media="screen" type="text/css" />说明,我们模板是根据这个CSS来布局网页的,于是我们就打开网站目录下面的templets\style\dedecms.css.然后来分析一下CSS的构成。

    我们根据主页的调用,来研究CSS这样容易理解。我们打开主页模板,找到:

    <div class="w960 center clear mt1">/*这句是控制除了网站头部和友情链接的所有结构样式*/

    那么 w960 center clear mt1 都定义了什么呢?我们打开DEDECMS.CSS 找打相关的定义。

    /*---------- stock ---------*/ 
    .center{ 
        margin:0px auto; 定义了CSS模块的边缘位置都是0,也就是这个center的层 距离上右下左都是0px;
    } 
    .w960{ 
        width:960px; 定义了整体的宽度为960px;
        /*position:relative;*/ 
    } 
    .pright .infos_userinfo { 
        margin-bottom: 0px; 定义了首页右部下的 互动中心的下面边缘为0px;
    } 
    .mt1{/* ( margin-top * 1 ) */ 
        margin-top:8px; 定义了mt1的顶部边缘为8px;
    } 
    .pright .mt1{ 
        margin-top:0px; 定义了pright 下面的mt1顶部边缘为0px;
    } 
    .mt2{/* ( margin-top * 2 ) */ 
        margin-top:16px; 顶部边缘为16px;
    } 
    .clear{ 
        overflow:hidden; 如果clear层里面的内容超出了 层的范围 就隐藏起来。
    } 
        
             <div class="pleft">这个pleft 的定义 没有在dedecms.css 中,但是我们会发现一句话
    @import url("layout.css");
    @import url("page.css");
    这说明,在dedecms.css 中引用了 page.css 和layout.css 这两个样式表,于是我们就在page.css 中找到了pleft 的定义
    .pleft{
    width:712px;定义了宽度
    float:left;该层向左浮动
    overflow:hidden;超出范围则隐藏
    }
        <div class="bignews">
         在该层下面调用的是新闻头条的内容,看看它的css
    .index .bignews{
    width:424px;
    height:400px;
    float:right; 向右浮动
    border:1px solid #DFF2F5;表示边框线用 #dff2f5的实体颜色填充
    background:url(../images/headbg-top.gif) repeat-x;背景图片为 headbg-top.gif   并且横向平铺
    overflow:hidden;超出则隐藏。
    }
    所以,我们看到头条的这部分是在flash幻灯片右边显示,并且加上了浅蓝色的边框线。
        <!--头条-->
            <div class="onenews">       再来看看 onenews是如何定义的。
            .index .bignews .onenews{
    margin:0 3px 0 3px; 左右外边距分别空3个像素
    padding:7px 6px;上左内边距分别空7,6个像素
    border-bottom:1px dashed #EBEBEB;下边框加一个 #ebebeb的虚线
    }
    所以我们看见头条的文章左右都有一定的距离,并且下面还有一个虚线显示       
    </div>
          <!-- /onenews -->
              这个下面调用的是以往的头条,默认的有4篇文章,调用了d1 d1arc 2个css
    .index .bignews div.d1{
    padding:6px 10px;
    clear:both;这句话是清除浮动,如果不加它,大家可以试试看,是不是 d1 这个层就跑到 头条的右边了。
    width:406px;
    overflow:hidden;
    }
    .index .bignews div.d1arc{
    margin-right:12px;
    width:190px;
    float:left;因为此时要调用4篇文章,改文章是2*2排列的,如果不加这个属性,新闻就应该垂直排列了(因为你刚才用clear:both 清除浮动啦),大家试试看是不是这样的。
    height:24px;
    line-height:24px;行间距,即字体最底端与字体内部顶端之间的距离
    overflow:hidden;
    }
          <!--/头条-->
            <div class='newarticle'>最新文章</div>
    下面看看 newarticle 这个css吧,还是拿快学网的首页举例子,上面的这句是用来显示 “最近更新”那几个绿颜色字的,看看它是怎么定义的。    
       .index .bignews div.newarticle{
    height:24px; 高度
    background:url(../images/new-article.gif) 8px 3px no-repeat;背景图片在x轴8px 和y轴3px出出现
    font-size:0px;
    color:#fff;
    }    所以,我们能看到那个 最近更新 并且还有一个横条,其实它是个图片,大家右键图片另存为看看就知道了
    <ul class="c2 ico1">
                    这里面调用了 c2 和ico1 两个 css
    .index .bignews ul.c2{
    width:416px;
    padding:0px 4px 0px; 内边距为 上0 右4下0
    clear:both;清除浮动 和上面的意思一样
    overflow:hidden;
    }
    ico1 这个css 在layout.css 中了。
    .ico1 li{
    padding-left:16px; 指的是 新闻列表左内边距为16px
    background:url(../images/ico-1.gif) 7px 11px no-repeat; 背景在7px,11px 处出现,所以我们看到最新文章的列表左边都有一个小黑点,这个小黑点就是 ico-1.gif
    }
                 </ul>
               </div>
        <!-- /bignews --> 到此,中部的头条新闻和最近更新已经分析完了。
        <div class="flashnews">
               看看flash的 css 定义
    .index .flashnews{
    width:280px;
    height:192px;
    overflow:hidden;
    float:left;这句决定了,flash 的新闻列表在 头条的左边显示。如果你把bignews 和flashnews 的float 属性互换一下应该是上面结果呢?大家试试看。
    }
           </div>
        <!-- /flashnews -->
        <div class="latestnews">这边是特别推荐调用的样式,还是来看看css
    .index .latestnews{
    width:280px;
    height:200px;
    margin-top:8px;
    float:left;
    }
    .index .latestnews dl dd{
    padding:2px 5px;
    }
    .index .latestnews ul a{
    color:#555;
    }

    以上就是dedecms怎么修改css的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:css
    上一篇:css外部样式表怎么写 下一篇:dw怎么创建css文件
    Web大前端开发直播班

    相关文章推荐

    • css clip属性怎么用• css text-indent属性怎么用• css 内阴影怎么做• css grid-columns属性怎么用
    1/1

    PHP中文网