【发布时间】:2012-01-01 06:48:28
【问题描述】:
我对 jQuery 不是特别擅长,所以最好有一个完整的代码解决方案。
函数将:
- 获取浏览器屏幕的 70% 宽度。
- 将该宽度转换为其对应的像素值
- 使用从转换/计算中获得的值设置
#mainContainer的最大宽度。
这是我要设置max-width 的容器的 CSS 样式:
#mainContainer {
background-image: url(bg3.jpg);
background-repeat: repeat;
background-color: #999;
width: 70%;
padding: 0;
min-width: 940px; /* 940px absolute value of 70%. */
margin: 0 auto;
min-height: 100%;
/* Serves as a divider from content to the main container */
-webkit-border-radius: 10px;
border-radius: 10px;
}
【问题讨论】: