简体   繁体   English

如何使用HTML / CSS创建具有相同宽度和不同高度的照相馆?

[英]How do I create a photo gallery with same widths and different heights using HTML/CSS?

I am a beginner to HTML and CSS. 我是HTML和CSS的初学者。 I want to create a photo gallery where all the columns are the same width, but each photo could have a different height. 我想创建一个图片库,其中所有列的宽度相同,但是每张照片的高度都可以不同。 But I want all the photos to "hug" each other, so that the photos in the second row may not start in the same vertical position as each other. 但是我希望所有照片彼此“拥抱”,以便第二行中的照片可能不会以彼此相同的垂直位置开始。 How do I accomplish that? 我该怎么做? Just saw something about columns - maybe that would work? 刚刚看到有关列的内容-也许行得通吗? I'm grateful for any help available! 感谢您提供的任何帮助!

You could create an HTML page which contains div s for each column. 您可以创建一个HTML页面,其中每一列都包含div

You could then either use your CSS stylesheet to place the columns together: - either float all these column div to left (refer to W3C school's CSS floating ), or by - using relative or absolute position ing (refer to W3C school's CSS positioning ) and give each div an X and Y coordinate. 然后,您可以使用CSS样式表将各列放在一起:-将所有这些列div浮动到左侧(请参阅W3C学校的CSS float),或者-使用relativeabsolute position (请参阅W3C学校的CSS定位 ),并且给每个div一个X和Y坐标。

Then give each column div a preset width (refer to W3C school's CSS width and max-width ). 然后为每个列div一个预设宽度(请参阅W3C学校的CSS width和max-width )。

Every item in a column will then move to a new row (when it has static positioning, which is default for most tags). 然后,列中的每个项目都会移动到新行(当它具有静态定位时,这是大多数标签的默认设置)。 So just give each image in that column the same fixed with an you should be fine... 因此,只要给该列中的每个图像加上相同的固定前缀,就可以了……

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

相关问题 如何使用HTML和JavaScript创建交互式照片库 - How do I create an interactive photo gallery using HTML and JavaScript Rails / CSS:如何制作不同宽度的图像库? - Rails/CSS: How do I make a gallery of images of different widths? CSS,我想要 3 个不同高度和宽度的 div 并排并排在顶部。 我该怎么做呢 - CSS, I want 3 divs of different heights and widths side by side and level at the top. How do I do this 不同高度和宽度的CSS Sprite - CSS Sprites with different heights and widths 使用css水平对齐不同高度和未知宽度的元素 - Horizontally aligning elements of different heights and unknown widths using css 我如何使用 html css 和 bootstrap 创建照片拼贴 - how do i create a photo collage with html css and bootstrap 如何在输入元素上创建具有不同 colors 和宽度/高度的重叠边框? - How to create a overlapping border with different colors and widths / heights on a input element? 如何创建灵活的 div 容器,将浮动行为与动态宽度和高度结合起来? - How do I create flexible div containers that marry float behavior with dynamic widths and heights? 如何在 css 网格中使不同高度的内容具有相同的高度? - How do I make content of different heights the same height in css grid? 如何创建具有特定宽度和高度的 div 的砌体布局? - How do you create masonry layout with divs of specific widths and heights?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM