CSS 图像放置方式取决于屏幕分辨率
如果您导航到 http://magee.darkslidedesign.com,您将在 jQuery Slides 的主页上看到图像。幻灯片的两侧都有一个“上一页”和“下一页”按钮。
我将这些图像放置在以下 CSS 中的某个位置...
#slides .next,#slides .prev {
position:absolute;
margin-top: -215px;
width:24px;
height:43px;
display:block;
border: 0;
}
#slides .next {
margin-left: 827px;
}
如果一个人的分辨率较低或较高,我需要一些帮助来尝试找出使这些箭头保持在 1600x900 分辨率的同一位置的最佳方法。
帮助?
If you navigate to http://magee.darkslidedesign.com you will see images on the main page in jQuery Slides. On either side of the slide, there is a "previous" and "next" button.
I have these images placed in a certain location in the following CSS...
#slides .next,#slides .prev {
position:absolute;
margin-top: -215px;
width:24px;
height:43px;
display:block;
border: 0;
}
#slides .next {
margin-left: 827px;
}
I need some help trying to figure out the best way to have these arrows stay at the same spot they are in 1600x900 resolution if a person has lower or higher resolution.
Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯...布局有点时髦...你可以做的一件事是删除
.prev
上的margin-left: 100px;
,删除margin-
,将.next
上的 left: 827pxright:0px;
添加到.next
,最后添加position:relative到60% 宽的容器,用于容纳幻灯片 div。您可能还想将
min-width: 750px;
放置到同一个 60% 宽的 div 中。如果您始终希望它们保持在同一位置,请为 60% 宽的 div 指定 800px 左右的固定宽度 (
width:800px
)。Hm... the layout is kinda funky... one thing you can do is remove
margin-left: 100px;
on.prev
, remove themargin-left: 827px
on.next
, addright:0px;
to.next
, and lastly addposition:relative
to the 60% wide container that holds the slides div. You may also want to put amin-width: 750px;
to that same 60% wide div.if you always want them to stay in the same spot, give the 60% wide div a fixed width of 800px or so (
width:800px
).修复这个问题非常困难,因为 html 代码首先是无效的。另外,在箭头上设置绝对位置并不是明智之举,因为它开始非常依赖于标题......而它应该仅依赖于滑块本身。看来当你改变位置时:absolute;在#slides .next,#slides .prev 内,滑块将停止正常工作。感觉就像滑块被放置在
.prev
所在的任何位置。所以 .prev 就像一个占位符。基于这些原因,我坚信,仅从 CSS 的角度无法解决这个问题。我建议优化您的 HTML,使其有效。并且可能使用不同的滑块。因为,通常将箭头放在滑块外部看起来像这样:
[ 查看输出 ]
很抱歉,我无法给您具体的答案,但我希望当您了解基本概念有多么简单时..您会重新考虑使用该滑块(因为我假设滑块 DOM 结构不是最佳选择。)此外,从技术上讲,您只需找到一个具有独立箭头的滑块(我个人喜欢 jQuery Orbit 插件)并简单地使用我的滑块结构的基本概念。因为,在这种情况下,您只需使
#hero_images
滑动并将 prev 和 next 函数挂接到箭头上,瞧!一些提示:
/
结束。之前。
.someimg {border: 1px Solid black;}
)。因此要避免无效的xhtml,然后在顶部添加预定义的img值你的 css:img {border: 0px;}
ul
列表中。It is very difficult to fix this as the html code is not valid as a first thing. Also, having position absolute on your arrows is not a wise thing to do, as it starts to very dependent of the header..while it should be depending on only the slider itself. It appears that when you change the position: absolute; inside
#slides .next,#slides .prev
, then the the slider stops working correctly. It almost feels, like the slider is being put wherever.prev
sits. So the .prev is like a placeholder.Based on those reasons, I strongly believe, that you cannot fix this problem from CSS point of view only. I recommend to optimize your HTML, make it valid. And possible use a different slider. Because, usually placing the arrows outside the slider looks something like this:
[ View output ]
I'm sorry that I cannot give you concrete answers, but I hope that when you understand how easy the basic concept is.. you will reconsider using that slider (as I'm assuming that the sliders DOM structure is not optimal.) Also, technically you simply find a slider that has stand-alone arrows (I personally like the jQuery Orbit Plugin) and simply use my basic concept of the slider structure. Because, in that case you only need to make the
#hero_images
slide and hook the prev and next functions to the arrows, and voila!Some pointers:
/
in xhtml.</body>
in the footer..someimg {border: 1px solid black;}
). So to avoid non-valid xhtml, then add predefined img value on the top of your css:img {border: 0px;}
ul
list..尝试这样的事情:
Try something like this :