仿微信页面

html文件

<!DOCTYPE html>
<html>
<head>
    <title>微信</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0"><!--网页屏幕自动适应手机-->
    <link rel="stylesheet" type="text/css" href="./css/wechat.css">
</head>
<body>
    <header>
        <label>微信(88)</label>
        <div class="icon_box">
            <img src="./img/search.png">
            <img src="./img/add.png">
        </div>
    </header>
    <main>
        <ul class='user-list'>
            <li class="user-item">
                <img class= 'photo' src="./img/photo1.jpg">
                <div class="msg">
                    <label>南开大学信息化</label>
                    <p>"贝贝"通过XX分享的二维码加入了群聊</p>
                </div>
                <div class='time'>周五</div>
            </li>
            <li class="user-item">
                <img class= 'photo' src="./img/photo2.jpg">
                <div class="msg">
                    <label>联合国</label>
                    <p>王洪杰:好的好的</p>
                </div>
                <div class='time'>昨天</div>
            </li>
        </ul>
    </main>
    <footer>
        <div class="footer-item">
            <img src="./img/wechat_active.png">
            <label>微信</label>
        </div>
        <div class="footer-item">
            <img src="./img/contact.png">
            <label>通讯录</label>
        </div>
        <div class="footer-item">
            <img src="./img/find.png">
            <label>发现</label>
        </div>
        <div class="footer-item">
            <img src="./img/me.png">
            <label>我</label>
        </div>
    </footer>
</body>
</html>

css文件

body,html {
    padding: 0;
    margin: 0;
    font-family: 微软雅黑;
}
header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;/*justify-content定义了元素在横轴上的对齐方式*/
    height: 3em;
    background: #eee;
    line-height: 3em;
    padding: 0 1em;
    color: #333;/*字体颜色*/
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
}
header label {
    font-size: 14px;/*字体大小*/
    font-weight: bold;/*加粗*/
}
header .icon_box img {
    width: 1.2em;
    height: 1.2em;
    vertical-align: text-bottom;/*设置元素的垂直对齐方式。
    text-bottom     把元素的底端与父元素字体的底端对齐。*/
    margin-left: 0.5em;
}

footer {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    height: 4em;
    background: #eee;
    align-items: center;/*规定元素在纵轴位置的对齐方式*/
    position: fixed;/*规定元素的定位类型  
    fixed 生成绝对定位的元素,相对于浏览器窗口进行定位。
    元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定*/
    left: 0;
    bottom: 0;
    width: 100%;
}
/*
position: 
    fixed       生成绝对定位的元素,相对于浏览器窗口进行定位。
                元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。

    relative    生成相对定位的元素,相对于其正常位置进行定位。
                因此,"left:20" 会向元素的 LEFT 位置添加 20 像素。不脱离文档流
    static      默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。
    absolute    生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。
                元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。脱离文档流。若父级有relative,则相对于父级定位
 */
footer .footer-item * {
    display: block;
    text-align: center;/*规定元素中的文本的水平对齐方式。*/
}
.footer-item img {
    width: 2em;
}
.footer-item label {
    font-size: 12px;
}

.user-list {
    list-style: none;
    padding: 0;
    margin-top: 50px;
    margin-bottom: 70px;
}
.user-item {
    position: relative;
    margin-top: 5px;
}
.user-item img {
    width: 50px;
    height: 50px;
    position: absolute;
    left: 0.5em;
    top: 0.5em;
}
/**/
.user-item .msg {
    padding: 0.5em 66px;
}
.user-item .msg label {
    font-weight: bold;
    color: #333;
}
.user-item .msg p {
    margin: 0;
    color: #888;
    font-size: 12px;
    margin-top: 10px;
}
/**/
.user-item .time {
    position: absolute;
    right: 0.5em;
    top: 0.5em;
    width: 50px;
    height: 50px;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容