简体   繁体   English

Css 图像无法适应

[英]Css image wont adapt

why doesnt the image adapt to the css?为什么图像不适应 css? My intention is make the picture go to the side a bit, thats why i tried the margin but yeah.我的意图是让图片 go 稍微靠边一点,这就是为什么我尝试了边距但是是的。 Idk.同上。

html html




  
<div class="la">
  <center>
    <h1> GREET THE TEAM </h1>
  </center>
</div>

<img class="pic" src="duve.png">

</body>

</html>

css css

.pic {
  height: 500px; 
  width: 250px;
  margin: 50px;
  border: 5px solid black;

}

can you help me make the picture go to the side a bit from the left?你能帮我把图片 go 往左边一点吗? Ive tried a lot of things, but it wont work.我已经尝试了很多东西,但它不会工作。

Here you should use: margin-left: 50px instead of margin: 50px , because margin:50px means your top, right, bottom and left of the image will have a 50px gap在这里你应该使用: margin-left: 50px而不是margin: 50px ,因为margin:50px意味着你的图像的顶部、右侧、底部和左侧将有 50px 的间隙

This might be stupid but have you connected the CSS file to the HTML file you are working on?这可能很愚蠢,但是您是否已将 CSS 文件连接到您正在处理的 HTML 文件?

For example, if your CSS file's name is style.css then inside the tag of the HTML file you have to have:例如,如果您的 CSS 文件的名称是 style.css 那么在 HTML 文件的标签内,您必须具有:

<link rel="stylesheet" href="style.css">

Edit: Be careful about the location of the HTML and the CSS files, if they are in different directories then you have to change the href accordingly.编辑:注意 HTML 和 CSS 文件的位置,如果它们位于不同的目录中,则必须相应地更改 href。

Example, if style.css is higher than the HTML file in the file hierarchy then href should be href="../styles.css"例如,如果 style.css 在文件层次结构中高于 HTML 文件,则 href 应为href="../styles.css"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM