CSS:根据屏幕大小对齐元素

时间:2012-08-17 17:51:23

标签: css jsp alignment

所以我正在编写一个需要根据查看器屏幕大小调整元素大小的程序。程序在jsp / sql / xhtml / css中,我有几个问题。

有没有办法通过将屏幕宽度保存到jsp变量来选择css文件?

有没有办法将div对齐到另一个div下面并使用上面的div作为它的一种容器?这个问题有点复杂

目标:在其下方放置带有文字标签的图片。问题:div是父div的一部分,div提供的图像将根据屏幕大小而改变。

这就像我正在做的事情。

<div id="container">
<div id="inner">
    <div class="1">--stuff</div>
    <div class="2"><img src="server:8080/project?minutes=720&width=<%= out.print(width) %> </div> <-- want to align under this
    <div class="3">--stuff</div>
</div>
<div id="label"> <--Want this div aligned underneath "2"
    <div class="1">2.0</div> <-- Want the text at 25% of the image (right)
    <div class="2">4.0</div> <-- Want the text at 50% of the image (right)
    <div class="3">6.0</div> <-- Want the text at 75% of the image (right)
    <div class="4">8.0</div> <-- Want the text at 100% of the image (right)
</div>
</div>

2 个答案:

答案 0 :(得分:2)

你想要做什么 - 响应式设计 - 非常酷,但也变得非常复杂。这需要一些学习,但CodeSchool有一个名为Journey Into Mobile的高质量课程,涵盖自适应屏幕尺寸,应该让你走在正确的轨道上。

答案 1 :(得分:0)

您需要深入了解自适应设计,媒体查询和流体布局。
如上所述,Codeschool确实有很好的课程涵盖这些领域。