简体   繁体   English

如何为相册设置样式?

[英]How to style a photo gallery?

I am looking for a method to design a photo gallary, I am currently using table but not sure if its a correct method to do it or not, also not sure about styling. 我正在寻找一种设计照片库的方法,我目前正在使用桌子,但不确定是否正确的方法来做,也不确定样式。

It has many images, upload is used to upload photos and message is used to show upload messages. 它有很多图像,上载用于上载照片,消息用于显示上载消息。

I just need to show the images and allow users to save images on the server, and show the messages, (uploaded / can not upload). 我只需要显示图像,并允许用户将图像保存在服务器上,并显示消息,(已上传/无法上传)。 I can show the images, save them and send the messages to the message section but not sure how to style it . 我可以显示图像,保存图像并将消息发送到消息部分,但不确定如何设置样式

Another problem is that I need all images to be in the same size, as each is in different size now. 另一个问题是我需要所有图像都具有相同的大小,因为每个图像现在都具有不同的大小。

I need it to be the same on all browsers. 我需要在所有浏览器上都一样。

<table>
<tbody>
<tr>
    <td><img 1></td>
    <td>upload photo btn</td>
    <td><label>message</label></td>
    <td><img 3></td>
    <td>upload photo btn</td>
    <td><label>message</label></td>
</tr>
</tbody>
</table>

Semantically tables should be used for tabular data. 语义表应用于表格数据。

Check out the answer to this question for some options. 查看此问题的答案以了解一些选项。 Depending on the age of the browsers you want to support, you could also consider using a flex box layout . 根据您要支持的浏览器的年龄,您还可以考虑使用弹性框布局 Flex box is nice and easy to code but not fully supported in all browsers yet. Flex box非常好用,易于编码,但尚未在所有浏览器中完全支持。

According to me this shouldn't be accomplished using tables, the better way to do is by using CSS3 column-count property, this way you can cut-split your content to whatever number of columns you want to, this way you don't have to use tables too.. 根据我的说法,这不应该使用表来完成,更好的方法是使用CSS3 column-count属性,这样您就可以将内容分割成任意数量的列,而不必也必须使用表格。

Demo 演示版

Demo (Added -webkit support) 演示 (添加了-webkit支持)

html, body {
    width: 100%;
    height: 100%;
}

.wrap {
    column-count: 3;
    -moz-column-count: 3;
    -webkit-column-count: 3;
}

.holder {
    border: 1px solid #f00;
}

img {
    max-width: 100%;
}

Note: column-count CSS3 property is not widely supported, but there are many polyfills available out, you can search online and use it for cross browser compatibility 注意: column-count CSS3属性不受广泛支持,但是有很多可用的polyfill,您可以在线搜索并将其用于跨浏览器兼容性

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

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