前端 模拟百度网页界面

2021/12/8 23:23:59

本文主要是介绍前端 模拟百度网页界面,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

html:网⻚显示的内容

css:网⻚显示的内容的属性

JavaScript:网⻚显示的内容的逻辑

英文感叹号!:快速生成一个标准的网⻚

        避免中文乱码

html的标签

1 a 跳转标签

        href:跳转链接

<a href="链接">名称</a>

<a class="a1" href="http://news.baidu.com/">新闻</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

   2 div 容器标签

        <div></div>

        宽度一定占据网⻚的一整行,高度默认由内容自动撑大如果手动设定了高度的话,他的高度就会固定,默认效果会失效

3 img 图片标签

        <img src="链接" alt="提示信息">

<img src="https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" alt=".jpg">

css的编写

1、在标签的上标签里面,添加属性【class选择器】,给选择器取个名字

2、在head标签里面,添加【style】标签(如果已经有了,不用重复添加)

3、class选择器,使用【点语法】进行html、css的连接

.logo{
            text-align: center;
        }

让logo那个图片居中

常用的css属性

文字颜色:color

文字装饰:text-decoration : line-through(中间划线、underline(下划线、none(不划线

背景颜色:background-color

高度:height 单位:px 像素

字体大小:font-size

内容对⻬方式(容器内):text-align :left center(居中  right

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>百度一下,你就知道</title>
    <style>
        .a1{
            color: black;
            text-decoration: none;
        }
        .head{
            height: 100px;
        }
        .left{
            float: left;
        }
        .right{
            float: right;
        }
        .logo{
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="head">
        <div class="left">
            <a class="a1" href="http://news.baidu.com/">新闻</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://www.hao123.com/">hao123</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://map.baidu.com/">地图</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://live.baidu.com/">直播</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://haokan.baidu.com/?sfrom=baidu-top">视频</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://tieba.baidu.com/index.html">贴吧</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="https://xueshu.baidu.com/">学术</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="">更多</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div class="right">
            <a class="a1" href="">设置</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="a1" href="">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
    </div>
    
    <div class="logo">
        <img src="https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" alt=".jpg">
    </div>

</body>
</html>

实现效果

 

&nbsp ; : 代表一个空格

<div class="left"> </div>,<div class="right"> </div>要再封装在一个<div class="head"> </div>容器里,不然会之后的容器出现些问题

导致下面的logo不能居中

 



这篇关于前端 模拟百度网页界面的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程