简单的HTML页面添加CSS
就是把上一个HTML页面https://blog.csdn/qq_41306364/article/details/101439925效果分离开来,独立写一个SCC样式。
效果图
大概就是这个样子,虽然和原本的网页差异还是很大,但此次精进,将每个div里的图片大小、字体属性和背景色在CSS中统一设置,代码更加整洁。
使用到的图片
CSS如何链接到页面中
在头部添加如下一行代码即可。
<link rel="stylesheet" type="text/css" href="css/1.css">
HTML代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/1.css">
<script type="text/javascript" src="js/1.js"></script>
</head>
<body>
<div class="d1">
<button>设为默认浏览器</button>
<img src="imgs/1.png" />
</div>
<div class="d2" align="center">
<form action="">
<img alt="" src="imgs/baidu_web.png"> <input class="in1"
type="text">
<button>搜索</button>
<div>
<input name="what" type="radio" value="百度" checked="checked" />百度 <input
name="what" type="radio" value="谷歌" />谷歌 <input name="what"
type="radio" value="淘宝" />淘宝
</div>
</form>
</div>
<div class="d3">
<div align="center">
<img alt="" src="imgs/baidu.png">
<div class="dd1">
<font>百度</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/xinlang.png">
<div class="dd1">
<font>新浪网</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/58.png">
<div class="dd1">
<font>58同城</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/aiqiyi.png">
<div class="dd1">
<font>爱奇艺</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/taobao.png">
<div class="dd1">
<font>淘宝网</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/jingdong.png">
<div class="dd1">
<font>京东商城</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/weipinhui.png">
<div class="dd1">
<font>唯品会</font>
</div>
</div>
<div align="center">
<img alt="" src="imgs/xiecheng.png">
<div class="dd1">
<font>携程旅行</font>
</div>
</div>
</div>
<div class="d4">
<img src="imgs/Logo.png">
<div>页面设置</div>
</div>
</body>
</html>
CSS代码
body {
background-image:
url("file:///G:/briup-code/work1-workspace/jd1911-html/WebContent/imgs/bg.jpg");
font-size: small;
}
.d1 {
margin-top: 20px;
}
.d1 button {
margin-left: 80px;
color: #FFFFFF;
background-image: linear-gradient(rgb(241, 168, 74), rgb(219, 110, 24));
border: 1px solid rgb(219, 110, 21);
border-radius: 2px;
box-shadow: rgb(247, 202, 127) 0px 0px 0px 1px inset;
padding: 2px 4px;
cursor: pointer;
font-size: small;
}
.d1 img {
float: right;
margin-right: 90px;
}
.d2 {
margin-top: 10px;
}
.d2 .in1 {
height: 30px;
width: 400px;
}
.d2 button {
height: 30px;
}
.d2 div {
margin-right: 200px;
margin-top: 10px;
}
.d3 {
width: 1300px;
margin-left: 180px;
margin-top: 80px;
}
.d3 div {
float: left;
margin-right: 25px;
margin-bottom: 25px;
width: 270px;
height: 160px;
border: 1px;
background-color: #FFFFFF;
}
.d3 img {
margin-top: 50px;
margin-bottom: 30px;
height: 50px;
width: 147px;
}
.d3 .dd1 {
background: rgb(250, 250, 250) none repeat scroll 0% 0%;
height: 30px;
bottom: 0px;
line-height: 30px;
}
.d3 .dd1 font {
margin-left: -214px;
}
.d4 {
background: rgba(242, 242, 242, 0.98) url("/static/img/noise.png")
repeat scroll 0% 0%;
border-top: 1px solid rgb(216, 216, 216);
bottom: 0px;
height: 50px;
padding-top: 12px;
position: fixed;
text-align: center;
width: 100%;
}
.d4 img {
float: left;
}
.d4 div {
background-image:
url("file:///G:/briup-code/work1-workspace/jd1911-html/WebContent/imgs/noise.png");
float: right;
}
总结
今天添加CSS样式,全是静态的,也没有过渡效果,就很基础的页面。
更多推荐
写一个简单的HTML页面及添加CSS样式
发布评论