2013-05-07 62 views
2

enter image description here如何在Twitter引导中对图像进行响应组合?

我想要上面的五个不同的图像加入,因为这是一个网页的标题部分。

我使用lavalamp插件,它的工作原理,但网页失去其响应能力。在不同的设备上,标题不会显示在一行中。

我试图将它插入引导。我插在引导CSS文件LavaLamp的CSS代码行,如下所示:

.lavaLampWithImage { 
    margin-top:10px; 
    position: relative; 
    height: 55px; 
    /* width: 734px;*/ 
    /*width:780px;*/ 
} 

.lavaLampWithImage li { 
    float: left; 
    list-style: none; 
} 

.lavaLampWithImage li.back { 
    background: url("res/arrow.png") no-repeat right -30px; 
    z-index: 0; 
    padding-top:59px; 
    padding-left:40px; 
    position: absolute; 
} 

.lavaLampWithImage li.back .left { 
    background: url("res/arrow.png") no-repeat top left; 
    height: 30px; 
} 

.lavaLampWithImage li a { 
    z-index: 20; 
    display: block; 
    float: left; 
    position: relative; 
    overflow: hidden; 
} 

.mm { 
    border:0px; 
} 

#navbar { 
    /*margin-left:152px;*/ 
    /*padding-top:60px;*/ 
    padding-top:1px; 
    /*width:727px;*/ 
} 

及相关的HTML代码部分如下:

<div class="span6"> 
    <div id="navbar"> 
     <ul class="lavaLampWithImage" id="1"> 
      <li><a href="index.html"><img class="mm" src="res/1.png" width="300" height="60" alt="home" onClick="location.href='index.html'"/></a></li> 
      <li class="current"><a href="index.html"><img class="mm" src="res/Home-n.png" width="120" height="60" alt="home" onClick="location.href='index.html'"/></a></li> 
      <li><a href="http://eywaz.com/sit2/MTA-2Website21-02/mta"><img class="mm" src="res/blog.png" width="120" height="60" alt="contact us" onClick="location.href='http://eywaz.com/sit2/'"/></a></li> 
      <li><a href="help.html"><img class="mm" src="res/Help-n.png" width="120" height="60" alt="about us" onClick="location.href='help.html'"/></a></li> 
      <li><a href="contactus.html"><img class="mm" src="res/Contact_us-n.png" width="120" height="60" alt="contact us" onClick="location.href='contactus.html'"/></a></li> 
     </ul> 
    </div> 
    <div class="clear"></div> 
</div> 

如何使它响应?

请尽早回复。

在此先感谢。

+0

做演示在jsfiddle中,图像的宽度和高度都太大了... – SaurabhLP 2013-05-07 11:56:23

回答

1

首先从您的图片标签中删除特定的宽度和高度,像波纹管:

<li><a href="index.html"><img class="mm" src="res/Home-n.png" alt="home" onClick="location.href='index.html'"/></a></li> 

然后在CSS中写:

@media only screen and (max-width:720px){ 
    .lavaLampWithImage li img { 
     max-width:100%; 
    } 
} 

,并在这个媒体查询给li元素的特定宽度的百分比。

0

我不是100%确定你对响应图像的含义。但如果你只是想调整根据屏幕宽度图像,你可以尝试这样的事:

.lavaLampWithImage { 
    margin:10px 0 0; 
    padding:0; 
    display:block; 
    position: relative; 
    width:100%; 
} 
.lavaLampWithImage li { 
    display:inline-block; 
    list-style: none; 
    background-color:green; 
    width:15.38%; 
} 
.lavaLampWithImage li:first-child { 
    width:38.45%; 
} 
.lavaLampWithImage li a, .lavaLampWithImage li a img { 
    display:block; 
    width:100%; 
} 

和HTML:

<div class="span6"> 
    <div id="navbar"> 
     <ul class="lavaLampWithImage" id="nav1"> 
      <li><a href="index.html"><img class="mm" src="http://www.upsdell.com/BrowserNews/img/ban_300x60.png" alt="home" onClick="location.href='index.html'"/></a></li><li class="current"><a href="index.html"><img class="mm" src="http://www.motive.co.nz/glossary/img/banner-120x60.gif" alt="home" onClick="location.href='index.html'"/></a></li><li><a href="http://eywaz.com/sit2/MTA-2Website21-02/mta"><img class="mm" src="http://www.motive.co.nz/glossary/img/banner-120x60.gif" alt="contact us" onClick="location.href='http://eywaz.com/sit2/'"/></a></li><li><a href="help.html"><img class="mm" src="http://www.motive.co.nz/glossary/img/banner-120x60.gif" alt="about us" onClick="location.href='help.html'"/></a></li><li><a href="contactus.html"><img class="mm" src="http://www.motive.co.nz/glossary/img/banner-120x60.gif" alt="contact us" onClick="location.href='contactus.html'"/></a></li> 
     </ul> 
    </div> 
    <div class="clear"></div> 
</div> 

这里是一个jsfiddle

+0

它给所有5张图像之间的差距...和所有图像高度不一样... – 2013-05-07 13:06:07

+0

如果使用'inline-block'对空间li在html中(我之间没有空格,请参阅我的标记a nd jsfiddle),你可以设置'display:block; float:left;'而不是'display:inline-block;'在li元素上......应该也可以工作,并且不会对空格敏感。关于图像高度......你可以使用你分配给李元素的百分比来玩更多的东西(我在答案中更新了它们,而jsfiddle http://jsfiddle.net/7t7zQ/2/)...如果ul设置为100%李必须是这个的正确部分,这不是一个整数。 – 2013-05-07 14:19:02

+0

我测试它在我的合成物上,它调整mac(ff 20,safari 6.0.3,chrome 26,opr 12.15)和windows(ff 20,chrome 26,即9)上的所有东西,更宽的图像可以呈现一点点调整大小(您可以尝试通过使用不同的大小来修复该问题,以便您无需循环百分比,例如400和150而不是300和120)。 – 2013-05-07 15:01:10