设置盒子宽度为100%,给一个背景颜色,缩小浏览器窗口,然后拖动滚动条到右侧,右侧的部分区域为空白的解决方法

问题描述:

全屏时正常显示  宽度为百分之百,缩小屏幕拉动底部滚动条 原本宽度百分之百的盒子右侧有空白

 解决办法:只需要给设置百分之百的盒子添加一个属性: min-width: 值 设置成和底下盒子一样宽就可以了

min-width:表示盒子的最小宽度

 

全屏时效果:

 

缩小屏幕,拉动底部滚动条 原本宽度百分之百的盒子右侧有空白

解决后效果

 html代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<link rel="stylesheet" href="05.css">
</head>

<body>
	<header></header>
	<section></section>
	<section></section>
	<section></section>
</body>

</html>

 css样式如下:

header {
  height: 100px;
  width: 100%;
  min-width: 1200px;
  background-color: blue;
}

section {
  background-color: pink;
  width: 1200px;
  height: 300px;
  margin: 0 auto;
}
section:nth-child(3) {
  background-color: orange;
}
section:nth-child(4) {
  background-color: red;
}

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值