HTML制作百度首页

先给出我的网页成品图:

先说我的网页布局的几个要点:

  • 为了防止各个块之间互相造成影响,我们几乎整个网页都用div模块组合而成.
  • 为了在不同分辨率的屏幕和缩放的网页上保持原网页各元素相对位置不产生改变,居中的要么选择<center>居中,要么使用margin属性,不过要使用百分比。
  • 小图标都是用的截图抓取,使用div包含其,然后调整布局就可以。
  • 具体字体大小,字体颜色等到百度页面F12开发者模式抓取就可以了。

网页布局的分块:

  • top分块:包含新闻,hao123等div,input模块也在其中。
  • 百度图标分块:<center>居中。
  • 复合模块:包含输入框,摄像机图片div,百度一下提交框三个组成。此处因为设计的问题并不好看,可以进行改进,改进方法如下:
  1. 先使用一个大的div包含上述所提到的三个模块。
  2. 输入框居中且去边框。
  3. 相机图片居中。
  4. 后直接跟提交框,改变提交框像素以和div符合。
  • end模块:包含二维码和后两行。我将二维码看作一个div,下面两行各看作一个div,其中的每组文字也看成一组div,然后根据观察的像素调整div大小进行适配组合以达到效果。但不建议采用此方法。最后两行div内,各行中每组文字都用<a>元素包含,有空格处用&nbsp调整就好。

form表单提交的action为https://www.baidu.com/s,为什么要加s呢,因为我们搜索是模拟提交百度搜索请求。

使用form表单提交请求,?后附加的参数name为input的name,value为input中输入的值,name=value。而我们观察上方图片,可以发现?后加的是wd=CSDN,所以我们使input得name为wd即可。

以下为代码:

<html>
	<head>
		<title>
			百度一下,你就知道
		</title>
		<link href="../images/icon.ico" rel="shortcut icon" type="image/x-icon"/>
		<style>
			.top{
				height:100px;
				width:100%;
			}
			.menu{
				text-decoration:underline;
				height:50px;
				width:50px;
				line-height:50px;
				float:right;
				font-size:13px;

			}
			.more{
				float:right;
				height:50px;
				width:50px;
				font-size:14px;
				margin-right:20px;
				margin-top:15px;
			}
			.bTitle{
				width:100%;
				margin-top:10%;
			}
			._all{
				height:40px;
				width:645px;
			}
			._in{
				float:left;
				height:40px;
				width:500px;
			}
			._photo{
				height:40px;
				width:40px;
				margin-left:-2px;				
				float:left;		
			}
			._search{
				float:left;
			}
			._bottom{
				margin-top:13%;
				width:100%;
			}
			._dimension{
				width:100%;
				height:108px;
			}
			._four{
				width:400px;
				height:25px;
				margin-top:10px;
			}
			._more2{
				width:93px;
				height:25px;
				line-height:25px;
				text-decoration:underline;
				float:left;
				font-size:10px;
				color:#999;
			}
			._five{
				width:545px;
				hight:22px;
			}
			._more3{
				float:left;
				line-height:22px;
				font-size:10px;
				color:#999;
				height:22px;
			}
			._picture{
				float:left;
				height:22px;
				width:22px;
			}
		</style>
	</head>
	<body>
		<div class="top">
			<div class="more">
				<input style="background-color:#38f;color:#fff;border:none;width:60px;height:23px" type="button" value= "更多产品">
			</div>
			<div class="menu">设置</div>
			<div class="menu">登录</div>
			<div class="menu"><b>学术</b></div>
			<div class="menu"><b>贴吧</b></div>
			<div class="menu"><b>视频</b></div>
			<div class="menu"><b>地图</b></div>
			<div class="menu"><b>hao123</b></div>
			<div class="menu"><b>新闻</b></div>
		</div>
		<center>
		<div class="bTitle">
			<img src="../images/baidu.png"/>
		</div>
		</center>
		<form action="https://www.baidu.com/s">
			<center>
				<div class="_all">
					<div class="_in"><input id="wd" name="wd" type="text" 								style="height:40px;width:500px;"></div>
					<div class="_photo"><img src="../images/photo.png" height=40 width=40/></div>
					<div class="_search"><input type="submit" value="百度一下" style="background-color:#38f;color:#fff;width:107px;height:40px;"><div>
				</div>
			</center>
		</form>
		<div class="_bottom">
			<center>
				<div class="_dimension">
					<img src="../images/二维码.png"/>
				</div>
				<div class="_four">
					<div class="_more2" style="width:121px">把百度设为主页</div>
					<div class="_more2">关于百度</div>
					<div class="_more2">About Baidu</div>
					<div class="_more2">百度推广</div>
				</div>
				<div class="_five">
					<div style="width:85px;" class="_more3">©2018 Baidu</div>
					<div style="width:87px;" class="_more3"><ins>使用百度前必读</ins></div>
					<div style="width:53px;" class="_more3"><ins>意见反馈</ins></div>
					<div style="width:102px" class="_more3">京ICP证030173号 </div>
					<div class="_picture"><img src="../images/small1.png"/></div>
					<div style="width:174px;" class="_more3"><ins>京公网安备11000002000001号</ins></div>
					<div class="_picture"><img src="../images/small2.png"/></div>
				</div>
			</center>
		</div>	
	</body>
</html>

 

制作百度搜索页面需要一定的HTML和CSS知识。以下是一个简单的示例,供参考: ```html <!DOCTYPE html> <html> <head> <title>百度搜索</title> <style type="text/css"> body { background-color: #f0f0f0; font-family: Arial, sans-serif; } .container { max-width: 800px; margin: 0 auto; padding: 20px; background-color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); } .form-group { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 20px; } .form-group input[type="text"] { flex: 1; padding: 10px; border: none; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); font-size: 18px; line-height: 24px; color: #333; } .form-group button[type="submit"] { padding: 10px 20px; background-color: #3385ff; border: none; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); font-size: 18px; line-height: 24px; color: #fff; cursor: pointer; } .form-group button[type="submit"]:hover { background-color: #2977e8; } </style> </head> <body> <div class="container"> <form action="https://www.baidu.com/s" method="get"> <div class="form-group"> <input type="text" name="wd" placeholder="请输入搜索关键词"> <button type="submit">百度一下</button> </div> </form> </div> </body> </html> ``` 解释: - `<!DOCTYPE html>`:声明HTML文档类型。 - `<html>`:HTML文档的根元素。 - `<head>`:文档头部,包括了页面的元数据和引用的外部资源。 - `<title>`:文档标题,显示在浏览器的标签页上。 - `<style>`:定义文档的样式。 - `<body>`:HTML文档的主体部分。 - `.container`:定义一个容器,包含搜索表单。 - `.form-group`:定义一个表单组,包含搜索输入框和提交按钮。 - `action`:定义提交表单时要请求的URL地址。 - `method`:定义表单提交的HTTP方法,这里使用GET方法。 - `name`:定义表单字段的名称。 - `placeholder`:定义输入框的默认提示文本。 - `type="submit"`:定义一个提交按钮。 这段HTML代码生成的页面如下所示: ![百度搜索页面](https://i.imgur.com/5Zi6qkH.png)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值