为什么每当我调整图片大小时,它会让我的其他元素移动,尽管有足够的空间和一个完全不同的容器.
我有这个#内容容器和#图片容器,它们都显示为内联块,它们在页面的同一行中,由于某种原因,每当我在#图片容器中调整我的img的大小时,它也会将我的#容器向下推,尽管它有完全不同的容器和足够的大小.这可能是什么原因造成的?
以下是我的代码
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: sans-serif;
/* border: 1px solid red; */
}
header {
display: flex;
justify-content: space-between;
margin-bottom: 3rem;
background: black;
}
header a#logo {
color: floralwhite;
text-decoration: none;
text-transform: uppercase;
font-size: 2em;
font-weight: 900;
margin-left: 2rem;
margin-top: 8px;
}
header ul {
margin-right: 2rem;
height: 80px;
}
header ul li {
list-style: none;
display: inline-block;
margin-right: 8px;
margin-top: 1rem;
/* border: 1px solid red; */
padding: 8px;
}
header ul li a {
text-transform: uppercase;
text-decoration: none;
text-align: center;
font-weight: 900;
font-size: 1rem;
color: floralwhite;
padding: 8px;
transition: outline 0.2s, color 0.2s, background 0.2s;
}
header ul li a:hover, header ul li a#active {
outline: 1px solid black;
color: black;
background: floralwhite;
}
div#content {
margin-left: 8rem;
display: inline-block;
margin-top: 4rem;
position: relative;
}
div#content h1, div#content h2 {
font-weight: 900;
}
div#content h2 {
margin-top: -15px;
text-indent: 5px;
margin-bottom: 1rem;
}
div#content div#content2 {
width: 400px;
font-size: 1rem;
font-weight: 500;
text-indent: 5px;
}
div#content::after {
content: "";
height: 100%;
width: 3%;
background: black;
position: absolute;
top: 0px;
left: -4rem;
margin-left: 2rem;
}
span#pic, span#pic img {
height: 250px;
margin-left: 8rem;
/* margin-top: ; */
border: 1px solid white;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Andri Quin </title>
<link rel="stylesheet" type="text/css" href="Portfolio.css">
<link rel="icon" href="letter-a.png">
</head>
<body>
<header>
<a href="#" id="logo"> Andri </a>
<ul>
<li> <a href="Portfolio.html" id="active"> Home </a> </li>
<li> <a href=""> Info </a> </li>
<li> <a href=""> About </a> </li>
</ul>
</header>
<div id="content">
<h1> Hi! Im Andri Quin </h1>
<h2> Student Web Developer </h2>
<div id="content2">
<p> Im a student aspiring to be a fullstack web deveoper in the near future. I also studying game development as I love playing game as well.Please look forward my work in the near future. </p>
</div>
</div>
<span id="pic">
<img src="letter-a.png">
</span>
</body>
</html>
下面是一些图片:
Before resizing the picture. After resizing the picture for some reason my content on the left side was pushed down. 一百零二