2012-10-29 207 views
0

我为我的WordPress站点使用Twitter Bootstrap。问题是我只是将一个div制作成右侧栏,并在其上放置了一些图像,这似乎在我的桌面上运行良好,但是当我在笔记本上查看它时,它会更改其位置并向下移动。Div的位置不固定在不同的屏幕尺寸

这里是我的div和形象展示位置代码:

<div style="position:fixed; top:188px; right:0px; border:0px solid #f00; width:25px;"><a href="#"><img src="http://pearlacademy.com/wp/wp-content/uploads/2012/10/delhi.jpg" style="margin-bottom:5px;"></a> 
<a href="#"><img src="http://pearlacademy.com/wp/wp-content/uploads/2012/10/noida.jpg" style="margin-bottom:5px;"></a> 
<a href="#"><img src="http://pearlacademy.com/wp/wp-content/uploads/2012/10/jaipur.jpg" style="margin-bottom:5px;"></a> 
<a href="#"><img src="http://pearlacademy.com/wp/wp-content/uploads/2012/10/chennai.jpg" style="margin-bottom:5px;"></a> 
</div> 
+0

你为什么不给右上方宽度%,而thyan以像素为单位给予? –

+0

仍然不工作的家伙.......我无法理解为什么?? plzzz帮助我 –

+0

@马欣德拉辛格:尝试位置:绝对,而不是位置:固定 –

回答

0

五月这种做法会有所帮助,如果我想使用纯CSS,这将是财产以后这样的:

HTML:

<div class="sidebar"> 
    <div class="box">Your anchor tags here</div> 
</div> 

CSS:

html, body { 
    height: 100%; 
} 

div.sidebar { 
    position:fixed; 
    right: 0px; 
    width: 25px; 
    height: 100%; 
    border: 1px solid blue; /* just for developing, remove this later */ 
} 

div.box { 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    right: 0; 
    left: 0; 
    margin: auto; 
    border: 1px solid #f00; /* depends on you ;) */ 
    height: 100px; /* unfortunately you have to set height property :| */ 
} 

一个活生生的例子here

+0

thieks evryone帮助我....我现在解决了.......我isssue是与bootstrap阿尔图像自动调整大小根据屏幕大小,因为他们是响应式设计通过靴子和div我放置没有改变根据那.... –