2010-06-14 95 views
2

我可以定義邊框寬度。像定義邊框寬度(不是厚度)

.box{ 
    width:200px; 
    height:100px; 
    border-bottom:1px solid #000; 
} 

框寬度爲200px,但我想在底部只有100px邊框寬度。

alt text http://www.freeimagehosting.net/uploads/6ba3c54859.png

+0

你能提出一個你想做什麼的草圖嗎? – SWeko 2010-06-14 14:11:18

+2

這不是一個邊框,這是一個獨立於元素的線條。你甚至可以使用


。 – 2010-06-14 14:14:31

回答

1

這聽起來像你想要一半的邊界。奇怪,但可行,我想。這可以在Firefox,Chrome和Safari中使用。 MSIE我目前沒有在手,並可能導致問題。

這種方式的工作方式是有一個背景顏色的背景顏色是寬度的一半,比div.box高1個像素。我把灰色背景放在身體上,這樣你就可以看到它的工作。

<html> 
<style type="text/css"> 
body { 
    background-color: #ccc; 
    color: #000; 
} 
.box-border { 
    width: 100px; /* half as wide as .box! */ 
    height: 101px; /* just slightly taller than .box! */ 
    background-color: #000; 
    overflow: visible; /* .box, inside this, can go outside it */ 
} 
.box{ 
    width: 200px; 
    height: 100px; 
    background-color: #fff; 
} 
</style> 
<body> 
    <div class="box-border"> 
     <div class="box"> 
      The quick brown fox jumped over the lazy dog. 
     </div> 
    </div> 
</body> 
</html> 
2

號你得把另一個元素.box,這是100px的寬範圍內,並且邊框應用到這一點。

0

或你定義一個背景圖像那樣的: .box的{ 背景:網址(border.gif)不重複0底部;}

並且圖像是100像素寬,例如2px的喚起注意。