简体   繁体   English

如何根据浏览器大小调整DIV元素的大小?

[英]How to resize DIV element according to browser size?

So here's a project I'm doing for school: 所以这是我正在上学的一个项目:

http://graciousevents.co.uk/ http://graciousevents.co.uk/

The problem is when the browser is re-sized, the photo-gallery moves underneath each other and then the contact DIV gets pushed to the left. 问题是当调整浏览器的大小时,图库在彼此下方移动,然后将联系人DIV推到左侧。

How can I correct this so the contact div doesn't get pushed to the left. 我该如何纠正这个问题,以便联系人div不会被推到左侧。

A particular within the DIV selector, if you want strings to re-size with the browser, instead of pixels, use "em". DIV选择器中的特定字符,如果要使用浏览器调整字符串大小而不是像素大小,请使用“ em”。

Ex. 防爆。 div{ font-size: x em } div {font-size:x em}

Are you using percentages for the sizing? 您是否正在使用百分比进行尺寸调整? If you give the window a set size and use pixels when sizing everything should stay where it is when you resize the window. 如果给窗口设置大小并在调整大小时使用像素,则调整窗口大小时,所有内容都应保持在原处。

BEFORE: 之前:

width: 10%;

AFTER: 后:

width:500px;

Change CSS using width: 62.5714%; 使用宽度更改CSS:62.5714%; or Use Bootstrap CSS 或使用Bootstrap CSS

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

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