简体   繁体   English

为什么我的图像会水平而不是垂直?

[英]Why are my images going horizontal instead of vertical?

Here is an image of my code in a browser window that shows the images laying out horizontally instead of vertically. 这是我的代码在浏览器窗口中的图像,显​​示水平而不是垂直放置的图像。

Is this simply the product of my browser width, and the size I made my images? 这只是我的浏览器宽度和我制作图像的大小的乘积吗?

image of horizontal alignment 水平对齐的图像

 <div id="images"> <h3>Here is some design work that I have done</h3> <img id="img1" src="photos/bees_wax_final_logo.jpg" width="200px" height="300px" alt="beeswax" /> <img id="img2" src="photos/before-and-after.jpg" height="200px" width="200px" alt="beforeandafter" /> <img id="img3" src="photos/Brush-work-buildings.jpg" alt="brushwork" height="200px" width="200px" /> <img id="img4" src="photos/Cosmic-woman.jpg" alt="cosmic" height="200px" width="200px" /> <img id="img5" src="photos/cosmo_elephant.jpg" alt="cosmo" height="200px" width="200px" /> <img id="img6" src="photos/Dispersion_window.jpg" alt="dispersion" height="200px" width="200px" /> <img id="img7" src="photos/Free_dogs_drawing.jpg" alt="freedogs" height:="200px" width="200px" /> <img id="img8" src="photos/Graphic-vector-art-logo-copy.jpg" alt="vectorart" height="200px" width="200px" /> <img id="img10" src="photos/I_am_coming_for_you.jpg" alt="shark" height="200px" width="200px" /> <img id="img10" src="photos/keener_raw_honey_logo.jpg" alt="rawhoney" height="200px" width="200px" /> <img id="img11" src="photos/Magazine_cover.jpg" alt="magazinecover" height="200px" width="200px" /> <img id="img12" src="photos/moon_man_background.jpg" alt="moonman" height="200px" width="200px" /> <img id="img13" src="photos/Nature_Double_Exposure.jpg" alt="nature" height="200px" width="200px" /> <img id="img14" src="photos/purple_water.jpg" alt="purplewater" height="200px" width="200px" /> <img id="img15" src="photos/Surrealism-style.jpg" alt="surrealism" height="200px" width="200px" /> <img id="img16" src="photos/Surrealism.jpg" alt="surrealsim2" height="200px" width="200px" /> <img id="img17" src="photos/the_greener_lawn.jpg" alt="greenlawn" height="200px" width="200px" /> <img id="img18" src="photos/Window-correction.jpg" alt="windowcorrection" height="200px" width="200px" /> </div> 

If you want to show them vertically you can put a <br> after every image. 如果要垂直显示它们,可以在每个图像后放置一个<br> Then you can center the images in your CSS file so that it looks cleaner. 然后,您可以将图像置于CSS文件中心,使其看起来更干净。 There are other ways of doing this. 还有其他方法可以做到这一点。 This might be one of the easiest. 这可能是最简单的方法之一。

<div id="images">
    <h3>Here is some design work that I have done</h3>
    <img id="img1" src="photos/bees_wax_final_logo.jpg" width="200px" height="300px" alt="beeswax" />
    <br>
    <img id="img2" src="photos/before-and-after.jpg" height="200px" width="200px" alt="beforeandafter" />
    <br>
    <img id="img3" src="photos/Brush-work-buildings.jpg" alt="brushwork" height="200px" width="200px" />

Okay, quickest solutions would be to set a display: block on all the images to remove any floating around them using css. 好的,最快的解决方案是设置一个display: block所有图像使用css删除周围浮动的任何图像。 So they will stack vertically. 所以他们会垂直堆叠。

 #images img{ display: block; } 
 <div id="images"> <h3>Here is some design work that I have done</h3> <img id="img1" src="photos/bees_wax_final_logo.jpg" width="200px" height="300px" alt="beeswax"/> <img id="img2" src="photos/before-and-after.jpg" height="200px" width="200px" alt="beforeandafter"/> <img id="img3" src="photos/Brush-work-buildings.jpg" alt="brushwork" height="200px" width="200px"/> <img id="img4" src="photos/Cosmic-woman.jpg" alt="cosmic" height="200px" width="200px"/> <img id="img5" src="photos/cosmo_elephant.jpg" alt="cosmo" height="200px" width="200px"/> <img id="img6" src="photos/Dispersion_window.jpg" alt="dispersion" height="200px" width="200px"/> <img id="img7" src="photos/Free_dogs_drawing.jpg" alt="freedogs" height:="200px" width="200px"/> <img id="img8" src="photos/Graphic-vector-art-logo-copy.jpg" alt="vectorart" height="200px" width="200px"/> <img id="img10" src="photos/I_am_coming_for_you.jpg" alt="shark" height="200px" width="200px"/> <img id="img10" src="photos/keener_raw_honey_logo.jpg" alt="rawhoney" height="200px" width="200px"/> <img id="img11" src="photos/Magazine_cover.jpg" alt="magazinecover" height="200px" width="200px"/> <img id="img12" src="photos/moon_man_background.jpg" alt="moonman" height="200px" width="200px"/> <img id="img13" src="photos/Nature_Double_Exposure.jpg" alt="nature" height="200px" width="200px"/> <img id="img14" src="photos/purple_water.jpg" alt="purplewater" height="200px" width="200px"/> <img id="img15" src="photos/Surrealism-style.jpg" alt="surrealism" height="200px" width="200px"/> <img id="img16" src="photos/Surrealism.jpg" alt="surrealsim2" height="200px" width="200px"/> <img id="img17" src="photos/the_greener_lawn.jpg" alt="greenlawn" height="200px" width="200px"/> <img id="img18" src="photos/Window-correction.jpg" alt="windowcorrection" height="200px" width="200px"/> </div> 

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

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