简单HTML练手项目[HTML+CSS]

目录

作品介绍

效果展示

 代码部分

特别注意

1、搜索框

1、input输入框的边框线和背景色如何去掉

2、如何将搜索框改为圆角输入框

3、如何让搜索图标在搜索框内部显示

2、居中和对齐

HTML中让前后两个控件顶端对齐


作品介绍

今天用HTML和css制作一个简单的网易云音乐导航栏

效果展示

 代码部分

index.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link href="index.css" type="text/css" rel="stylesheet">
	</head>
	<body>
		<nav>
		<div class="d">
			<img class="one" src="wyyyy.png" alt="">
			
			<input class="btn" type="button" value="发现音乐" >
			<input class="btn" type="button" value="我的音乐" >
			<input class="btn" type="button" value="关注" >
			<input class="btn" type="button" value="商城" >
			<input class="btn" type="button" value="音乐人">
		    <input class="btn" type="button" value="下载客户端">
			 <input class="four" type="submit" value="登录">
			<input class="three" type="button" value="创作者中心">

			<form action="" method="get" class="top1">
				<input class="two" type="search" placeholder="音乐/视频/电台/用户">	
			   <div class="pic"><a href="#"><img src="seek.png" alt=""></a></div>
			</form>		
		</div>
		</nav>
	</body>
</html>

index.css

*{
	margin: 0;
	padding: 0;
}
.d{
	height: 50px;
	 font-size:0px;
	 margin-top: 0ch;
	background-color:bisque;
}
.one{
	width: 100px;
	height: 40px;
	margin: 0 auto;
	
}
.btn{
	margin: 0;
	width: 66px;
	height: 50px;
	border: 0ch;
    background-color:transparent;	
}
.top1 {
    margin-right: 10px;
    width: 200px;
    height: 22px;
	float: right;
    border: 0px;
    background-color: #ffffff;
    margin: 10px 0;
    border-radius: 10px;
	margin-right: 10px;
}
.two{
	width: 200px;
	height: 22px;
	float: left;
	display: inline-block;vertical-align: top;
	border-radius: 10px;
	background-color: white;
}
.pic {
    align-items: center;
    height: 30px;
    width: 30px;
    float: right;
	margin-top: -25px;
}
.pic img{
    height: 30px;
    width: 30px;
}
.three{
	float:right;
	margin-right: 10px;
	margin-top: 10px;
	border-radius: 10px;
	background-color:transparent;	
}
.four{
	float:right;
	margin-right: 5px;
    margin-top: 10px;
	border: 0ch;
	 border-radius: 10px;
	 background-color:transparent;	
}

特别注意

1、搜索框

1、input输入框的边框线和背景色如何去掉

要取消input默认的边框线,可以通过将css中边框线的属性值设为0,即可取消边框线的默认显示

 例如:border: 0px;

要取消input输入框默认的背景色,可以通过在css中设置background-color:transparent; 语句取消默认的背景色。

2、如何将搜索框改为圆角输入框

如若要让默认的矩形输入框变为圆角输入框,可以尝试在CSS中设置border-radius: 10px;以达到圆角输入框的显示效果。

3、如何让搜索图标在搜索框内部显示

例如下图这样的效果:

首先,先用一个form标签将要显示的搜索框和搜索图标包裹起来

 像这样:

<form action="" method="get" class="top1">
				<input class="two" type="search" placeholder="音乐/视频/电台/用户">	
			   <div class="pic"><a href="#"><img src="seek.png" alt=""></a></div>
			</form>	

然后再通过设置css样式以到达理想的效果

先设置form整体的css属性

.top1 {
    margin-right: 10px;
    width: 200px;
    height: 22px;
	float: right;
    border: 0px;
    background-color: #ffffff;
    margin: 10px 0;
    border-radius: 10px;
	margin-right: 10px;
}

然后再设置搜索框框的css属性

.two{
	width: 200px;
	height: 22px;
	float: left;
	display: inline-block;vertical-align: top;
	border-radius: 10px;
	background-color: white;
}

最后设置搜索图标的css属性(没错下面两个都是)

.pic {
    align-items: center;
    height: 30px;
    width: 30px;
    float: right;
	margin-top: -25px;
}
.pic img{
    height: 30px;
    width: 30px;
}

最后就在相应的标签里面应用对应的css资源就好了(代码资源可能需要微调)

2、居中和对齐

HTML中让前后两个控件顶端对齐

(只需一行代码就能实现)

display: inline-block;vertical-align: top;

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值