2013-05-07 37 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