Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

li span float left float right

Tags:

html

css

I need to do the following:

|text1| lots of text lots of text lots |text3|
lots of text lots of text lots of text lots 
of text

It is structured as:

<li><span>text1</span><span>text3</span><span>lots of text</span></li>

text3 is float right.

The problem is that I need to set a width on lots of text as I need the background colour to fill the entire width of the row. If I set it to float:left, it goes down a line and is not on the same line as text1 or text2.

like image 929
BobTurbo Avatar asked May 30 '26 13:05

BobTurbo


1 Answers

Like this

jsFiddle

span {
  float: left;
  display: inline;
}

span.withbg {
  width: 200px;
  background: red;
}
<ul>
  <li>
    <span id="left">text1</span>
    <span class="withbg">lots of text</span>
    <span id="right">text3</span>
  </li>
</ul>
like image 109
rrapuya Avatar answered Jun 01 '26 02:06

rrapuya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!