我有一个简单的标签,底部带有横幅和边框。如何停止在缩放时滑动这两个元素?我一直在寻找一种方法来放大和缩小两个元素。即使经过几个小时的搜索,我仍无法获得所需的输出。我尝试了this和另一条帖子,内容是从px更改为em。
我的html标签:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
<div id="header">
<img class="logo" src="./style/logo.jpg" width= 895 height= 160">
</div>
<div id="container-border">
</div>
</body>
css:
#header
{ padding:0 20px;
display:block;
margin:0 auto;
background: #D6D6D6 url(background.jpg) repeat-x;
height: 205px;
width: 1500px;
position: center;
}
#container-border {
width: 1538px;
height:900px;
margin-left:260px;
border-color: black;
border-width: 1px;
border-style: solid;
}
答案 0 :(得分:1)
您首先需要将内容包装在包含DIV中
HTML
<div class="site-content">
<div id="header">
<img class="logo" src="./style/logo.jpg" width= 895 height="160">
</div>
<div id="container-border">
</div>
</div>
请注意新的DIV
.site-content
。在这里您可以将网站内容居中并控制网站内容的宽度。
这是我的codepen:https://codepen.io/arlcode/pen/aRpWZo
我也建议您不要将静态宽度/高度用于移动动态目的。您还将要使用比ID更多的类,因为ID是特定的,但是类允许您一次操纵多个DIV。