黑马程序员前端web入门:新浪新闻

黑马程序员前端web入门:新浪新闻

几点学习到的:

  1. 设置li无圆点: list-style: none;
  2. 设置a无下划线:text-decoration: none;
  3. a属于行内元素,高度hegiht不起作用,可以设置 display: block; 把它变成块元素。此时,设置水平居中 text-align: center; , 设置垂直居中 line-height: 30px; 。
  4. 网页布局什么时候用图片背景,什么时候用img标签https://blog.csdn.net/smlljet/article/details/103321869
  5. 如果采用background显示图片,需要设置 padding-left 防止内容与背景重叠。
html 复制代码
<!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>
        *{
            margin:0;
            padding:0;
            box-sizing: border-box;
        }
        
        li{
            list-style: none;
        }

        a{
            text-decoration: none;
        }
        
        .news{
            width: 360px;
            height: 200px;
            
            margin: 100px auto;
            

        }

        .news .hd{
            height: 34px;
            background-color: #eee;
            border: 1px solid #dbdee1;
            border-left: none;
        }
        
        .news .hd a{
            height: 34px; 
            width: 48px;

            display: block;

            margin-top: -1px;
            
            text-align: center;
            line-height: 30px;

            border-top:3px solid #ff8400 ;
            border-right: 1px solid #dbdee1;
            background-color: #fff;

            font-size: 14px;
            color:#333;

        }

        .news .bd{
            padding: 5px;
        }

        .news .bd li{
            padding-left: 15px;
            background: url('./img/quare.png');
            background-repeat: no-repeat;
            background-position: 0 center;
            background-size: 5px;
        }
        .news .bd li a{
            padding-left: 20px;
            background: url('./img/picture.png');
            background-repeat: no-repeat;
            background-position: 0 center;
            background-size: 15px;

            font-size: 12px;
            color: #666;
            
            line-height: 24px;
        }
        .news .bd li a:hover{
            color: #ff8400;
        }
    </style>
</head>
<body>
    <div class="news">
        <div class="hd">
            <a href="#">新闻</a>
        </div>
        <div class="bd">
            <ul>
                <li><a href="#">新闻1新闻1新闻1新闻1新闻1新闻1</a></li>
                <li><a href="#">新闻2新闻2新闻2新闻2新闻2新闻2</a></li>
                <li><a href="#">新闻3新闻3新闻3新闻3新闻3新闻3</a></li>
                <li><a href="#">新闻4新闻4新闻4新闻4新闻4新闻4</a></li>
                <li><a href="#">新闻5新闻5新闻5新闻5新闻5新闻5</a></li>
                <li><a href="#">新闻6新闻6新闻6新闻6新闻6新闻6</a></li>
            </ul>
        </div>
    </div>
</body>
</html>
相关推荐
电子云与长程纠缠19 分钟前
UE5制作六边形包裹球体效果
开发语言·python·ue5
IT_陈寒25 分钟前
Vite动态导入把我坑惨了,原来要这样用才对
前端·人工智能·后端
砍材农夫25 分钟前
物联网 基于netty构建mqtt协议规范(遗嘱与保留消息)
java·开发语言·物联网·netty
DFT计算杂谈28 分钟前
KPROJ编译教程
java·前端·python·算法·conda
觅_31 分钟前
前端学习后端的时候 选择一个技术
前端·学习
独泪了无痕34 分钟前
CryptoJS:数据安全的JavaScript加密利器
前端·vue.js·node.js
froginwe1143 分钟前
Python3 迭代器与生成器
开发语言
xiaoshuaishuai81 小时前
C# 签名异常与Gas预估失败调试方案
开发语言·网络·tcp/ip·c#
xiaoshuaishuai81 小时前
C# Gemini 辅助网络安全漏洞分析
开发语言·web安全·c#
发现一只大呆瓜1 小时前
一文搞懂 Vite 处理CommonJS包、按需编译逻辑及 Rollup 插件兼容规则
前端