开发者

How to make text all on the same line when adding div tags?

开发者 https://www.devze.com 2023-04-13 00:26 出处:网络
I have added div tags to text on the same line as I wanted to add the mouseover feature but now all the text is on different lines. How do I make it so all the text is on the same line?

I have added div tags to text on the same line as I wanted to add the mouseover feature but now all the text is on different lines. How do I make it so all the text is on the same line?

HTML:

<div style="margin-top:30px;" />
<center>
<table height="50" width="400" cellpadding="0" cellspacing="0">
<tr>
<td>
<center>

<hr size="1" color="#585858" width="82%"></hr>

</center>
<center>
<div class="about">
<font face="helvetica" size="2" color="#585858">About Us</div>
&nbsp;&nbsp;&nbsp;<div class="about">Accessibility</div>
&nbsp;&nbsp;&nbsp;<div class="about">Contact Us</div>&nbsp;&nbsp;&nbsp;</font></div>

<font face="helvetica" size="2" color="#585858">&copy;2011&nbsp;-&nbsp;Privacy
</font></center>


</center>
</td>
</tr&开发者_C百科gt;
</table>
</center>

CSS:

.about:hover {
font: 13px helvetica;
text-decoration: underline;
}

Thanks!

James


A div generates a box and therefore a new line, try using span instead.

Additionally, you are using old, depreated HTML Tags like font or attributes like height/width. Try to find some good tutorial about css and use css instead of html where possible.


Write float:left or display:inline-block in the div css because div is a block element that's why it comes below each other. So; that's why we use float & inline-block to force the div takes it's actual width:

div{
 float:left;
}


It looks like you are trying to create a horizontal list of links (except you haven't included the <a> elements yet).

The two general techniques are:

  1. Use float
  2. Use display: inline-block

You should also replace the div elements with list item elements. Listamatic has many examples.

You should also stop using layout tables, and replace the deprecated <font> and <center> elements with CSS, and use CSS margins instead of series of non-breaking spaces.


are block level elements so they break the line and go into next line u can try with float:left or float:right or u can use display:inline feature .

Have a look at this example http://jsfiddle.net/T5rBU/ .

Also if u want to just have text inside div and align them in one line rather use span elements and they get aligned automatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消