常见前端错误

例1:响应式布局

<!doctype html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>点击获取评论内容</title>
<style type="text/css">
	*{
		box-sizing: border-box;
	}
	html,body{
		width: 100%;
	}
	.wap{
		width: 98%;
		margin: 0 auto;
		border: 1px solid #888888;
		border-radius: 3px;
		text-align: center;
	}
	.title{
		width: 100%;
		border-bottom: 1px solid #888888;
	}
	.pinglun{
		width: 100%;
		text-align: center;
		padding: 10px;
	}
	.wap .fuzhizhantie{
		width: 90%;
		margin: 10px auto;
		max-width: 200px;
		background: #0000ff;
		color: #ffffff;
		border-radius: 3px;
	}
	.renwu{
		width: 90%;
		margin: 10px auto;
		background: #0000ff;
		color: #ffffff;
		border-radius: 3px;
	}
	.bottom-area{
		text-align: center;
	}
	.bottom-area p{
		color: #ff0000;
	}
</style>
</head>

<body>
<div class="wap">
	<div class="title">
		游戏很不错
	</div>
	<div class="pinglun">
		好游戏,非常适合坐车玩的游戏。很喜欢,玩了很长时间了,会一直玩的!
	</div>
	<button class="fuzhizhantie">一键复制刷新</button>
</div>
<div class="bottom-area">
	<p>每次刷机前,请做以下2个任务。页面打开时间务必超过一分钟!!!</p>
	<p>(任务执行日期:7月4号到7月10号)</p>
	<button class="renwu">任务1一键复制,贴到浏览器访问,停留超过一分钟</button>
	<button class="renwu">任务2一键复制,贴到浏览器访问,停留超过一分钟</button>
	<br>
	<p>靖江,辽源,秦皇岛做任务3和任务4</p>
	<button class="renwu">任务3一键复制,贴到浏览器访问,停留超过一分钟</button>
	<input class="renwu" type="button" value="任务4一键复制,贴到浏览器访问,停留超过一分钟"/>
</div>
</body>
</html>

1、为何class=wap里面3个,为何在3的外面text-align3个都可以居中对齐,但是如果分别给这3个加text-align,按钮没办法居中呢?

因为给button设置,起作用的是button的内容,为他的父级设置,起作用的是他的父级的内容button标签。修改如下:对button加个display:block;

2、<button class="renwu">任务3一键复制,贴到浏览器访问,停留超过一分钟</button>与<input class="renwu" type="button" value="任务4一键复制,贴到浏览器访问,停留超过一分钟"/>区别?  建议使用button对,里面的内容可以自适应


例2:

margin标记可以带一个、二个、三个、四个参数,各有不同的含义。

margin: 20px;(上、下、左、右各20px。)
margin: 20px 40px;(上、下20px;左、右40px。)
margin: 20px 40px 60px;(上20px;左、右40px;下60px。)
margin: 20px 40px 60px 80px;(上20px;右40px;下60px;左80px。)

在css中使用margin可以将margin-top,margin-right,margin-bottom,margin-left,缩写为一个标记,顺序为上右下左(顺时针)。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值