day05

今天学到了什么

盒子的模型

    /* 
            box-sizing:border-box
            给元素border,padding不会改变它的width,height
初始情况box-size=content-box
             */

横线

        
        width: 1000px;
        color: red;
    }
    </style>
</head>
<body>
    <div>
        <hr>
    </div>

背景图片、

 div{    
         
        background:red;
   background-image: url(images/logo.png);
  background-position:center center; 
   background-repeat: no-repeat;
        height: 100px;
      margin-left: auto;
      margin-right: auto;  
    }
第二种
两个div 一个div控制背景颜色
            一个div控制图片大小( /* background-size: 100% 100%; ()cover*/)和位置( margin-left: auto;
      margin-right: auto;)

要注意


1png.png

float

1.png

float和父元素

  /* 
        父元素不设置高度,子元素float,父元素的高度会坍塌
         */
         /* 
         如何让父元素重新获取高度
         1.给父元素 overflow:hidden;
         2.给父元素公共样式row
         .row:after{
             content:"";
             display:table;
             clear:both;
         }
          */

导航的几种做法

-1 li的浮动(左浮动 右浮动 调整位置margin)


6.png

-2 相对位置和绝对位置

(大的div相对位置 就可以直接使用left top来移动物体 (   /* 相对定位就是元素在页面上正常的位置 相对定位一般不使用right,bottom */)   position:relative;想动的position:absoute)
xiang

)
.content-body1{
width: 1000px;
margin-left: auto;
margin-right: auto;
margin-top: 10PX;
margin-bottom: 10px;
}
.search{
margin-top: 50px;
height:60px;
background:#eee;
position: relative;
line-height: 60px;
}
.s-left{
position: absolute;
left:0;
}
.s-right{
position: absolute;
right:0;color: #44cef6;
}
.s-right2{
position: relative;
}
.i-three{
position: absolute;
top: 50%;
margin-top: -8px;
}
.s-content{
position: absolute;
left:400px;width:240px;height:20px;
}
.s-content1{
position:relative;
width:240px;
}
button{
position:absolute;top:50%;margin-top: -9px;

        right:5px;width:23px;height:22px;
        background: url("images/icon4.png");border:none;
    }
    .input1{
        padding-left:20px;border:1px solid black;
      
        width:220px;height:28px;background:#eee;
    }

<div class="content-body1">
<div class="search">
<div class="s-left">
<span>发布时间</span>
<span>∨价格∧</span>
<span>环保节能∧</span>
</div>
<div class="s-content">
<div class=" s-content1">
<input class="input1" type="text" placeholder="搜索">
<button></button>
</div></div>
<div class="s-right">
<div class="s-right1">
<span class="s-three"><img class="i-three" src="images\wenhao.png" alt=""></span>
<span>了解环保家居建材环保评级标准</span>
</div></div>
</div>
</div>

  • 3 内联块和内标签的使用 注意如果有问题(父元素font-size=0)

元素水平居中(因为居中那一点 所以需要margin移动某某一半)

8.png

搜索框去锐化 和 button的移动 和背景图片的移动(绝对位置和相对位置的应用)

9.png

悬浮定位(可以作为狗皮膏药)

 div{
            width:20px;
            height:50px;
            background:red;
            position:fixed;
           /*right:10px;
            bottom:130px;*/ (选取位置 和相对位置使用差不多)
        }

绝对位置的堆叠顺序

10.png

父元素下第一个选中 所有选中 和单独

种类选中

  .right a{
            font-size: 12px;
        }(和单独种类选中)
   .search>div{
            width:100px;
            height:58px;
            border:1px solid #333;
            position:absolute;
        }(某某后所有div)
父亲-p{}

图片自适应

   img{
            display:block;
            margin-left: auto;margin-right: auto;
            height:auto;
            max-width: 100%;
           }
    </style>
</head>
<body>
<img src="images/down.jpg" />
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...
    剑残阅读 13,302评论 0 8
  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 5,912评论 0 1
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,698评论 1 92
  • 不会用代码框,所以看着有些乱套,,,,html部分 <!DOCTYPE html> 迅雷看看 ...
    这就是个帅气的名字阅读 5,661评论 0 0
  • 今夜无眠,我一个人坐在办公室。窗外城市的灯火星星点点,望去已有些许黯淡,而我的思绪一如脱缰的野马在自...
    西风瘦水阅读 3,720评论 0 5

友情链接更多精彩内容