Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width of a inline element? [duplicate]

Tags:

css

I want to design a tab header. The html code is,

<div class="tab-header">
    <a href="" class="current">tab1-title</a>
    <a href="">tab2-title</a>
</div>

Now I need to apply a background image to the current class, too make effect like this, enter image description here

But the inline element a is not big enough for this background image, so I adjust the width and height of the element a. But the adjustment failed, the width/height of the element did not change.

How could I get the right effect?

Thanks.

like image 358
Jichao Avatar asked Feb 28 '11 02:02

Jichao


2 Answers

To apply width, set css property 'display' to either 'block' or 'inline-block'.

block: the element will sit in a single line. In such case you may want to set float so links are in the same line;

inline-block; the element will have height, width, etc, and multiple elements will sit in the same line (block).

like image 152
James Chen Avatar answered Sep 27 '22 20:09

James Chen


Set the display property to inline-block, and then you can set the width, height, and vertical-align as necessary.

like image 34
Josh Lee Avatar answered Sep 27 '22 22:09

Josh Lee