简体   繁体   English

图像堆叠在一起而不是内联

[英]images are stacking on top of one another instead of inline

我想看什么 I've been at this for days. 我已经待了好几天了。 In my website, the images are stacking up on top of each other, so it appears to be a single image instead of 4. Also, it is displaying itself on top of other elements on the page, like the text. 在我的网站中,图像相互堆叠,因此看起来像是单个图像而不是4。而且,它还显示在页面上其他元素(如文本)的顶部。 In Dreamweaver it shows up how I want, but in the browser, it shows as described above. 在Dreamweaver中,它显示了我想要的方式,但是在浏览器中,它如上所述。

What I want: the four images to display side by side above the page header About Us. 我想要的是:四个图像在页面标题“关于我们”的上方并排显示。 Here is the code: 这是代码:

<center>
<span class="images">
<img src="images/aboutUs/longJumpBoy.jpg" alt="longJumpBoy" longdesc="images/aboutUs/longJumpBoy.jpg">
<img src="images/aboutUs/groupPic.jpg" alt="groupPic" width="214" longdesc="images/aboutUs/groupPic.jpg">
<img src="images/aboutUs/kidOnTrack.jpg" alt="kidOnTrack" longdesc="images/aboutUs/kidOnTrack.jpg">
<img src="images/aboutUs/throwingKids.jpg" alt="throwingKids" longdesc="images/aboutUs/throwingKids.jpg">

 </span> 

</center>

    <h1>About Us</h1>        
<br /><br />
    <h2>Who are we?</h2> 
<p>
    The team is a USA Track and Field (USATF) certified running club. We compete locally and nationally. Our athletes are able to train in all disciplines in track and field, but the team is specialized in distance running. Our runners are registered to run in both USATF and Amateur Athletic Union (AAU) league events.
    <br />
    Practices are held primarily on El Paso's East side.
</p>
 <header>
    <h2>Mission Statement</h2>
</header>

Here is the CSS 这是CSS

.images img {
    display:inline-block;
    border-color: rgb(191,224,104);
    border-width: 3px;
    margin: auto
}

EDIT: I edited the code and here is the link to my jsFiddle: http://jsfiddle.net/JaLb7/ . 编辑:我编辑了代码,这是我的jsFiddle的链接: http : //jsfiddle.net/JaLb7/ Now, the image in browser displays above the text, but only one of them. 现在,浏览器中的图像显示在文本上方,但只有其中之一。 Also, when I scroll, the image does not scroll with the page, but rather the text scrolls behind the image. 另外,当我滚动时,图像不会随页面滚动,而是文本会在图像后滚动。

Image of my issue: 我的问题图片: 在浏览器中预览-显示问题

You could use display, text-align and white-space: 您可以使用显示,文本对齐和空格:

Your HTML 您的HTML

<span class="images">
<img src="images/aboutUs/longJumpBoy.jpg" alt="longJumpBoy" longdesc="images/aboutUs/longJumpBoy.jpg">
<img src="images/aboutUs/groupPic.jpg" alt="groupPic" width="214" longdesc="images/aboutUs/groupPic.jpg">
<img src="images/aboutUs/kidOnTrack.jpg" alt="kidOnTrack" longdesc="images/aboutUs/kidOnTrack.jpg">
<img src="images/aboutUs/throwingKids.jpg" alt="throwingKids" longdesc="images/aboutUs/throwingKids.jpg">
 </span> 

Basis CSS to apply 适用的基础CSS

.images {
display:block;
text-align:center;
white-space:nowrap;
}

Notice , should be a block element like <p> or <div> or even <figure> if that's accurate. 请注意 ,如果准确的话,应该是<p><div>甚至是<figure>类的块元素。

<center> should not be used and is totally useless as soon as you know how to apply margin:auto; 一旦知道如何应用margin:auto; ;,就不应使用<center> ,它完全没有用margin:auto; and , or , text-align:center; 和或text-align:center; .

OK, so this is an amateur mistake. 好的,这是一个业余错误。 After digging through my stylesheet, I saw I had a img tag definition for styles (not part of a class) - which had a fixed positioning. 在浏览完样式表之后,我看到了样式的img标签定义(不是类的一部分)-位置固定。 We are looking much better now. 我们现在看起来好多了。

Thanks for all your help and suggestions, I did clean up my code per your recommendations - which helped in other ways. 感谢您的所有帮助和建议,我确实按照您的建议整理了代码-其他方面也有所帮助。

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

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