首页 > 其他分享 >1.2 仿百度Web Day2

1.2 仿百度Web Day2

时间:2022-10-30 18:01:28浏览次数:61  
标签:Web 1.2 color 标签 元素 Day2 li ul display

Day2

和前一天的页面一样, 但是改了一些规范, 并且加上了弹出框(简陋版).

image-20221029022344214

主要是改了首尾的引航栏, 将原来的直接使用a标签变成使用ul>(li>a)标签

成果

  1. 修改了首尾的引航栏, 将原来的直接使用a标签变成使用ul>(li>a)标签: 将ul>li标签通过css的display: inline-block标签修改为内联块标签, 使其可以在同一行排序.

  2. 实现了弹出窗口的使用 (见下<弹出窗口>)

  3. 了解了text-align: center的使用方法(块级元素使用才能居中, 内联元素无法居中), 也就是:
    <img src="" alt="" style="display:block; text-align:center"/>实现图片居中

  4. css中通过(width:1000px; margin:0 auto;): 在块元素中限定元素宽度, 然后可以使用margin:0 auto实现水平居中.

问题

  1. 依旧无法实现水平垂直居中.

  2.  /* 为什么这个标签组合能实现底部水平居中 */
     #footer {
         text-align: center;
         position: absolute;
         left: 0;bottom: 0;right: 0;
     }
    
  3. 搜索栏的间隔问题还没有解决

弹出窗口

弹出窗口其实主要是两个块级元素的组合. 也就是, 显示一个块级元素a, 不显示另外一个块级元素b(display: none;), 同时将这个不显示的块级元素添加上浮动position独立于其它元素, 当鼠标移动到a时, 使用伪类a:hover .b {display:block}b显示出来, 就有弹出窗口的效果了.

源码

css

/* 初始化 */
body, ul, li, div, span, a, form, input {
	margin: 0px;
	padding: 0px;
}
a {
	text-decoration: none;
}

/* 顶部 */
#header {
	padding: 10px;
}

ul.nav > li {
	display: inline-block;
	padding: 10px;
}

#header a {
	color: black;
	font-size: 12px;
}
#header a:hover {
	color: rgb(32, 120, 179);
}

/* 弹出窗口 */
.dropdown {
	position: relative;
	display: inline-block;
}
.dropdownMoreContent {
	display: none;
	position: absolute;
}
.dropdown:hover .dropdownMoreContent{
	display: block;
}

/* 图片 */
.image1 {
	text-align: center;
}

/* 搜索栏 */
.search {
	width:810px;
	height: 30px;
	margin: 0 auto;
}

.search > form > input:first-child{
	border-radius: 10px;
	width: 700px;
	height: 30px;
}

.search > form > input:nth-child(2){
	background-color: blue;
	color: white;
	border-radius: 10px;
	width: 100px;
	height: 30px;
	margin: 0;
	padding: 0;
}



/* 底部 */
#footer {
    text-align: center;
    position: absolute;
    left: 0;bottom: 0;right: 0;
}

#footer > ul > li > * {
	font-size: 5px;
	color: gray;
}

#footer a:hover {
	color: black;
}

html

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<title>百度一下,你就知道</title>

	<link rel="stylesheet" href="./css/style.css">
</head>
<body>

	<!-- 顶部导航栏 -->
	<div id="header">
		<ul class="nav">
			<li><a href="http://news.baidu.com/" target="_blank">新闻</a></li>
			<li><a href="https://www.hao123.com/?src=from_pc_logon" target="_blank">hao123</a></li>
			<li><a href="http://map.baidu.com/" target="_blank">地图</a></li>
			<li><a href="http://tieba.baidu.com/" target="_blank">贴吧</a></li>
			<li><a href="https://haokan.baidu.com/?sfrom=baidu-top" target="_blank">视频</a></li>
			<li><a href="http://image.baidu.com/" target="_blank">图片</a></li>
			<li><a href="https://pan.baidu.com/?from=1026962h" target="_blank">网盘</a></li>
			<li>
				<div class="dropdown">
					<a href="http://www.baidu.com/more/" target="_blank">更多</a>
					<div class="dropdownMoreContent">
						<a href="" class="more1">翻译</a>
						<a href="" class="more2">学术</a>
						<a href="" class="more3">文库</a>
						<a href="" class="more4">百科</a>
						<a href="" class="more5">知道</a>
						<a href="" class="more6">健康</a>
						<a href="" class="more7">营销推广</a>
						<a href="" class="more8">直播</a>
						<a href="" class="more9">音乐</a>
						<a href="" class="more10">查看全部百度产品</a>
					</div>
				</div>
			</li>
		</ul>
	</div>


	<!-- 图片 -->
	<div class="image1">
		<a href="https://www.baidu.com/s?wd=%E4%BA%8C%E5%8D%81%E5%A4%A7&sa=ire_dl_gh_logo_texing&rsv_dl=igh_logo_pc" target="_blank">
			<img src="https://www.baidu.com/img/pc_675fe66eab33abff35a2669768c43d95.png" alt="百度搜索" title="二十大" style="zoom:50%">
		</a>
	</div>

	<!-- 搜索栏 -->
	<div class="search">
		<form action="https://cn.bing.com/search" method="get">
			<input type="text" name="q" >
			<input type="submit" value="百度一下">
		</form>
	</div>

	<!-- 底层栏 -->
	<div id="footer">
		<ul class="nav">
			<li><a href="https://home.baidu.com/" target="_blank">关于百度</a></li>
			<li><a href="http://ir.baidu.com/" target="_blank">About Baidu</a></li>
			<li><a href="https://www.baidu.com/duty" target="_blank">使用百度前必读</a></li>
			<li><a href="https://help.baidu.com/" target="_blank">帮助中心</a></li>
			<li><a href="https://e.baidu.com/?refer=1271" target="_blank">企业推广</a></li>
			<li><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11000002000001" target="_blank">京公网安备11000002000001号</a></li>
			<li><a href="https://beian.miit.gov.cn/" target="_blank">京ICP证030173号</a></li>
			<li><a href="https://www.baidu.com/licence/" target="_blank">信息网络传播视听节目许可证 0110516</a></li>
			<li><span>互联网宗教信息服务许可证编号:京(2022)0000043</span></li>
		</ul>
	</div>

</body>
</html>

标签:Web,1.2,color,标签,元素,Day2,li,ul,display
From: https://www.cnblogs.com/Yiero/p/16841807.html

相关文章

  • 基于Cri-dockerd使用Kubeadm部署Kubernetes1.25集群
    1.前言介绍关于Kuebernetes的部署常用于部署K8s集群的工具和部署方式minikubekubeadm二进制包本文使用kubeadm部署方式K8s集群的部署有多种方式,而使用Kubeadm是......
  • JAVAWeb - HttpServletRequest
    一.Request入门HttpServletRequest:代表客户端的请求,通过http协议访问服务器,Http请求中的所有信息会被封装到HttpServletRequest,通过这个HttpServletRequest的方法,获得客户......
  • day2
    数据类型扩展publicclassDome03{  publicstaticvoidmain(String[]args){    //整数拓展:进制  二进制0b 十进制 八进制0  十六进......
  • C# 利用VS自带的WSDL工具生成WebService服务类
    WebService有两种使用方式,一种是直接通过添加服务引用,另一种则是通过WSDL生成。添加服务引用大家基本都用过,这里就不讲解了。那么,既然有直接引用的方式,为什么还要通过WSD......
  • 找到多个名为spring_web的片段。这是不合法的相对排序。有关详细信息,请参阅Servlet规
    问题描述:解决办法:1:检查pom.xml中是否包含多个spring-web字段;2:删除掉多余的spring-web.jar,保留一个即可;......
  • 一句话启动web服务--参考
    文档说明:只记录关键地方;python3python3-mhttp.server8000PHPphp-S0.0.0.0:8000-t.nodejsnpminstallhttp-server-g--registry=https://registr......
  • windows 2003 oracle 10.2.0.4 升级迁移到linux 11.2.0.4
    文档课题:windows2003oracle10.2.0.4升级迁移到linux11.2.0.4源端:windows200332位+oracle10.2.0.432位+双实例目标端:centos7.964位+oracle11.2.0.464位应......
  • JavaScript – Web Worker
    前言在上一篇<<单线程与执行机制>> 中,我们提到了WebWorker.它的诞生是为了解决JS主线程执行耗时计算时,导致UI无法及时更新的卡死现象.它的解决思路是把......
  • Android开发页面重定向导致WebvView.canGoBack一直返回true的解决方法
    Android开发页面重定向导致WebvView.canGoBack一直返回true的解决方法原因:打开页面A的时候重定向到页面B,页面B回退的时候回退到页面A,但是接着又重定向到页面B,所以canGoBack......
  • VS2017 IIS 部署.net core web项目
    直接上内容: 安装IIS这个不在重复,可百度搜索到。 点击IIS查看模块:查看是否安装了AspNetCoreModule模块,如果没有安装可下载:​​http://download.microsoft.com/downlo......