发表于: 2020-03-18 23:01:43

1 1375


编辑日报内容...

.今日完成的内容和收获:

(一)布局让header紧贴顶部

代码:

1.html部分

    <header class="head">

        <div class="box">

            <div class="box-l">找雇主</div>

                        <div class="box-r">找护工</div>

        </div>

        <img src="task6-1.png" alt="地址图标" class="location">

    </header>

 

2.css部分

.head {

    width100%;

    height4rem;

    background-color#5fc0cd;

    positionfixed;

}

.box {

    margin.5rem auto/* 让盒子水平居中 */

    width12rem;

    height3rem;

    background-color#55a8b3;

        line-height3rem;

    positionrelative;

    border-radius10px;

}

.box-l { /* 找雇主 */

    positionabsolute;

    left1rem;

    colorwhite;

    font-size1.5rem;

}

.box-r { /* 找护工 */

    text-aligncenter;

    floatright;

    width50%;

    height3rem;

    background-colorwhite;

    font-size1.5rem;

    border-radius10px;

    color#5fc0cd;

}

.location { /* 地址图标 */

    positionabsolute;           /* 垂直居中 */   

    top50%;

    transformtranslateY(-50%);  /* 垂直居中 */

    right1rem;

    width2rem;

    height2rem;

}

 

(二)布局让footer紧贴底部

1.html部分

 <footer class="foot">

        <div>

            <img src="task6-2.png" alt="house" class="foot-l">

            <br>

            <span>首页</span>

        </div>

        <img src="task6-3.jpg" alt="write" class="foot-m">

        <div>

            <img src="task6-4.jpg" alt="me" class="foot-r">

            <br>

            <span style="color: #bcbdbe;">我的</span>

        </div>

        

    </footer>

 

2.css部分

.foot {

    width100%;

    height5rem;

    background-color#f8fafb;

    positionfixed;

    bottom0;

    displayflex;  /* 采用flex布局 */

    align-itemscenter/* 在交叉轴的中点对齐 */

    justify-contentspace-around/* 每个项目两侧的距离相等 */

    border-top1px solid #e2eaec;

}

.foot span {

    color#5fc0cd;

}

.foot-l {

    width2rem;

    height2rem;

}

.foot-m {

    width5rem;

    height5rem;    

}

.foot-r {

    width2rem;

    height2rem;

}

 

(三)border边框渐变效果

1.线性渐变(linear-gradient

1)语法:必须至少要定义两种颜色,我们也可以设置一个起点或一个方向或者一个角度

background-image: linear-gradient(direction, color-stop1, color-stop2, ...);

2)默认情况下是从上到下渐变

background-image: linear-gradient(#e66465, #9198e5);

3)从左到右

background-image: linear-gradient(to right, red , yellow);

4)从左上角到右下角

background-image: linear-gradient(to bottom right, red, yellow);

 

(四)html超过部分显示为省略号

    overflowhidden/* 文字溢出隐藏 */

    text-overflowellipsis/* 文字超出容器宽度时,文字被隐藏的文字用省略号代替 */

    white-spacenowrap;  /* 强制文字不换行 */

 

text-overflowellipsis 属性只能用于块级元素或内块元素,对行内元素是不起作用的。

 

(五)CSS模拟下拉框

1.displaynonedisplayblock切换   将代码部分需要用到的地方摘选出来,用来练习模拟下拉框,能够实现只有鼠标放到小三角形时才可以让菜单显示

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <style>

        .main-h-l {

            floatleft;

            width6rem;    

            border-right2px solid;

            positionrelative;

            border-imagelinear-gradient(#fafbfb#999999#fafbfb)1 1 1;/* 颜色渐变效果 */

        }

        .select {

            list-style-typenone/* 去掉li的样式 */

            positionabsolute;

            top-1rem;

            right.5rem;

 

        }

        .main-p {

            floatright;

            positionabsolute;

            right0;

        }

         li {

            width6rem;

            height30px;

            background-coloryellow;

            border1px solid #999;

            line-height30px;

            positionrelative;

            left1rem;

            top2rem;

            displaynone/* 隐藏菜单 */

            text-aligncenter;

        }

        .select:hover li {

            displayblock;  /* 当鼠标悬浮在select上时,会显示出li菜单 */

        }

    </style>

</head>

<body>

    <div class="main-h-l">所在地

       

            <ul class="select">

                <a href="#" class="main-p"><img src="task6-5.png" alt="下拉框" ></a>

                    <li>北京</li>

                    <li>天津</li>

                    <li>上海</li>

            </ul>

    </div>

</body>

</html>

(六)main部分

1.html部分

<main class="main">

        <div class="main-h">

                <div class="main-h-l">所在地

                    <a href="#" class="main-p"><img src="task6-5.png" alt="下拉框" ></a>

                </div>

                <div class="main-h-m">食宿</div>

                <div class="main-h-r">病人情况</div>

        </div>

        <div class="text-1">

            <div class="bg-data"></div>

            <span>服务日期</span>

            <p class="data-2">2015-7-52015-7-12</p>

            <strong class="price">25/小时</strong>

            <div class="bg-jiantou"></div>

            <div class="bg-location"></div>

            <span>北京·通州·果园</span>

        </div>

    </main>

 

2.css部分

.main-h {

    width100%;

    height4rem;

    font-size1.3rem;

    line-height4rem;

    text-aligncenter;

    color#999999;

    border-bottom1px solid #999999;

}

.main-h-l {

    floatleft;

    width33%;

    border-right2px solid;

    border-imagelinear-gradient(#fafbfb#999999#fafbfb)1 1 1;/* 颜色渐变效果 */

}

.main-p {

    floatright;

    positionrelative;

    right.5rem;

}

.main-h-m{

    floatleft;

    width32%;

    border-right2px solid;

    border-imagelinear-gradient(#fafbfb#999999#fafbfb)1 1 1;

}

.main-h-r {

    floatleft;

    width33%;

}

 

.bg-location {   /* 雪碧图地址标 */

    width26pxheight25px;

    backgroundurl(css_sprites.png-95px -10px;

    positionabsolute;

    top6.2rem;

    left1.5rem;

}   

.bg-jiantou {   /* 雪碧图剪头标 */

    width20pxheight33px;

    backgroundurl(css_sprites.png-10px -10px;

    positionabsolute;

    right1rem;

    top50%;

    transformtranslateY(-50%);

}

.bg-data {  /* 雪碧图日期标 */

    width26pxheight25px;

    /*background: url('css_sprites.png') -49px -10px;*/

    background-imageurl(css_sprites.png);

    background-position-49px -10px;

    positionrelative;

    top1.5rem;

    left1.5rem;

}

.text-1 {

    width100%;

    height9.5rem;

    positionrelative;

    border-bottom1px solid #999999;

}

.text-1 span {

    positionrelative;

    left3.5rem;

    color#999;

}

.data-2 {

    positionrelative;

    left3.5rem;

    overflowhidden/* 文字溢出隐藏 */

    text-overflowellipsis/* 文字超出容器宽度时,文字被隐藏的文字用省略号代替 */

    white-spacenowrap;  /* 强制文字不换行 */

    width41%;

}

.price {

    positionabsolute;

    top3.9rem;

    right3rem;

    colorred;

}

目前最终实现的页面


.遇到的问题

1.遇到的问题,都通过自己查询百度和坑乎解决了

2.拿到页面之后,有时候会不知道如何去着手,一般都是边写边调整,慢慢的先将页面弄成大概的样子,之后在进行细节调整。有的时候实现的布局不一样了就会通过定位来进行调整,主要是绝对定位(脱离文档流)和相对定位(不脱离文档流)来进行调整

3.自己也在进行着比如用float浮动或者flex布局来实现同样的布局,尽可能的让自己对这些定位和布局有深一步的理解和熟练的应用

 

.明天的计划

1.最近有事情耽误了每天的日报

2.尽快将任务6完成

 

 

 

 

 

 

 

 



返回列表 返回列表
评论

    分享到