简体   繁体   English

关于 CSS - 使用 CSS position 属性,但它不起作用

[英]Regarding CSS - Using CSS position property but it is not working

I just would like to know what am I doing wrong?我只是想知道我做错了什么? I used the exact same code for positioning other images.我使用完全相同的代码来定位其他图像。 But for some reason, It is not working now.但由于某种原因,它现在不起作用。 Basically, I feel like my CSS is not working.基本上,我觉得我的 CSS 不工作。 I also trying to design links but the CSS part is not working.我也尝试设计链接,但 CSS 部分不起作用。

Hope it makes sense.希望这是有道理的。 Thanks and looking forward to hearing from you guys.谢谢并期待收到你们的来信。

HTML Part: HTML 零件:

<div id = 'last-part-of-the-side-news'>
  <img id = 'apple' src = 'images/wework.jpg'>
</div>

CSS Part: CSS 零件:

#last-part-of-the-side-news{
  float:left;
}

#apple{
  width: 230px;
  height: 140px;
  position:relative;
  bottom: 448px;
  left: 200px;
}

The image is positioned 448px above and 200px to the right of your div.图片位于 div 上方 448px 和右侧 200px 处。 Here is a snippet to illustrate the example:下面是一个片段来说明这个例子:

 #last-part-of-the-side-news{ float:left; width: 200px; height: 200px; background: blue; position: absolute; top: 448px; } #apple{ background: rgba(255,0,0,0.3); width: 230px; height: 140px; position:relative; bottom: 448px; left: 200px; }
 <div id = 'last-part-of-the-side-news'> <div id = 'apple'></div> </div>

If your div is at the top of the document, your image would be outside of the window.如果您的 div 位于文档顶部,则您的图像将位于 window 之外。

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

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