严格的流体布局| jQuery 插件
我今天有了这个想法,可以结合流体和固定宽度布局,并且还可以使响应式布局更快建造。它还将使布局中百分比的使用效果更好。
为此,我使用了与无框架网格系统类似的想法。
“逐列调整,而不是逐像素调整。”
我没有使用列,而是一次调整 1 个单位
的大小。 示例 jsFiddle 一次调整 10px
,该示例展示了这如何带来好处在使用百分比时。它通过将 @media
样式与 max-width
和 min-width
结合使用来实现此目的。
我遇到的问题是,您很快就会有很多 @media
样式,并且您必须手动输入每一个样式。所以我想它可以只使用一个相当简单的 jQuery 插件。然而,我对 jQuery 的了解有限,所以我对如何做到这一点只有一个模糊的想法,我已经在 jsFiddle。
以下是一些 CSS @media
样式:
@media only screen and (max-width: 249px) {.test.two {width: 240px}}
@media only screen and (max-width: 259px) and (min-width: 250px) {.test.two {width: 250px}}
...
@media only screen and (max-width: 1259px) and (min-width: 1250px) {.test.two {width: 1250px}}
@media only screen and (min-width: 1260px) {.test.two {width: 1260px}}
以及映射出来的jQuery 小提琴
$('.test.two').strictfluid(10px 240px 1260px); // Apply function
var resizeEvery = 'first (10px)';
var minWidth = 'second (240px)';
var maxWidth = 'third (1260px)';
var calculate = minWidth;
// First @media :
"@media only screen and (max-width: " + (min-width + (resizeEvery - 1)) + " ) {" + min-width +"}}"
calculate = calculate + resizeEvery;
// Middle @media's (Repeat While {calculate < maxWidth})
"@media only screen and (max-width: " + (calculate + (resizeEvery - 1)) + " ) and (min-width: " + (calculate) + " ) {" + (calculate) +"}}"
calculate = calculate + resizeEvery;
// Last @media :
"@media only screen and (min-width: " + (max-width) + " ) {" + max-width +"}}"
I had this idea today that could combine both Fluid and Fixed width layouts and also make responsive layouts faster to build. It would also make the use of percentages in layouts work better.
To do this I'm using a similar idea to the Frameless Grid system.
"Adapt column by column, not pixel by pixel."
Rather than using columns, I'm adjusting the size 1 unit
at a time. The example jsFiddle adjusts 10px
at a time, the example shows how this could be beneficial in using percentages. It does this by using @media
styles with max-width
and min-width
.
The problem I have run into is that you quickly have a lot of @media
styles, and you would have to manually enter every single one. So I figured it could just use a fairly simple jQuery plugin. However, I have a limited knowledge of jQuery so I have only a vague idea of how this would be done which I have mapped out in the jsFiddle.
Here is some of the CSS @media
styles:
@media only screen and (max-width: 249px) {.test.two {width: 240px}}
@media only screen and (max-width: 259px) and (min-width: 250px) {.test.two {width: 250px}}
...
@media only screen and (max-width: 1259px) and (min-width: 1250px) {.test.two {width: 1250px}}
@media only screen and (min-width: 1260px) {.test.two {width: 1260px}}
And the mapped out jQuery Fiddle
$('.test.two').strictfluid(10px 240px 1260px); // Apply function
var resizeEvery = 'first (10px)';
var minWidth = 'second (240px)';
var maxWidth = 'third (1260px)';
var calculate = minWidth;
// First @media :
"@media only screen and (max-width: " + (min-width + (resizeEvery - 1)) + " ) {" + min-width +"}}"
calculate = calculate + resizeEvery;
// Middle @media's (Repeat While {calculate < maxWidth})
"@media only screen and (max-width: " + (calculate + (resizeEvery - 1)) + " ) and (min-width: " + (calculate) + " ) {" + (calculate) +"}}"
calculate = calculate + resizeEvery;
// Last @media :
"@media only screen and (min-width: " + (max-width) + " ) {" + max-width +"}}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论