Home  >  Article  >  Web Front-end  >  A simple question about css, if you put Div and Span on the same line? _html/css_WEB-ITnose

A simple question about css, if you put Div and Span on the same line? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:20:421286browse

<table>  <tr>      <th style="width:180px;border:1px solid red">          <div>div</div>           <span>span</span>                 </th>  </tr>  </table>  


In the above code, if you can put span and div on the same line by adjusting the css of Span?

Note that the css properties of any element other than span cannot be adjusted. But you can turn span into other elements, and this element must support the attribute of background being an image.


Reply to discussion (solution)

No way. . The div has already filled the top part, and there is definitely no solution without changing the styles of other elements.

Or add a div
outside span like this:

    <table>      <tr>          <th style="width:180px;border:1px solid red">              <div>div</div>               <div><span>span</span></div>        </th>      </tr>      </table>

Does LZ have an answer? I can’t think of a way

        <table>      <tr>          <th style="width:180px;border:1px solid red">              <div>div</div>               <div style="position:relative;"><span style="position:absolute;top:-22px;left:0;">span</span></div>        </th>      </tr>      </table>


I forgot to write the style, so I added

span can only be positioned absolutely, left and top can be adjusted by yourself~~

f5d188ed2c074f8b944552db028f98a1
a34de1251f0d9fe1e645927f19a896e8
f08790ecf127edf8a9a088f607ffa48e
6c8624910a5be7e1fae035bb8801b606span54bdf357c58b8a65c66d7c19c8e4d114
dc6dce4a544fdca2df29d5ac0ea9906bdivd4e6ef3935d870d31c81823c096b9b03
01c3ce868d2b3d9bce8da5c1b7e41e5b
fd273fcf5bcad3dfdad3c41bd81ad3e5
>

f5d188ed2c074f8b944552db028f98a1

a34de1251f0d9fe1e645927f19a896e8
f08790ecf127edf8a9a088f607ffa48e

play:inline-block ;">div16b28748ea4df4d9c2150843fecfba68 

 
01c3ce868d2b3d9bce8da5c1b7e41e5b 
 fd273fcf5bcad3dfdad3c41bd81ad3e5 
;



Dude, why does one use div and the other span? Do you understand inline elements and block-level elements? First figure out which are inline elements and which are block-level elements, and then use them! Otherwise, your layout will be a big pit...

<table>    <tr>        <th style="width:180px;border:1px solid red">            <div style="float:left">                div            </div>            <div>                <span>                    span                </span>            </div>        </th>    </tr></table>
Span can only be positioned absolutely. Left and top can be adjusted by yourself~~

Absolute positioning is separated from the parent element, which is not good.

f5d188ed2c074f8b944552db028f98a1
a34de1251f0d9fe1e645927f19a896e8
f08790ecf127edf8a9a088f607ffa48e

45f98b85d12ffd0f5bb4738dac2f2b41span54bdf357c58b8a65c66d7c19c8e4d114

dc6dce4a544fdca2df29d5ac0ea9906bdiv16b28748ea4df4d9c2150843fecfba68
01c3ce868d2b3d9bce8da5c1b7e41e5b
fd273fcf5bcad3dfdad3c41bd81ad3e5
f16b1740fad44fb09bfe928bcc527e08

This is the real master!


f5d188ed2c074f8b944552db028f98a1
a34de1251f0d9fe1e645927f19a896e8

f08790ecf127edf8a9a088f607ffa48e

d7c496e2b56e9602d3477d3cad19d5b9span54bdf357c58b8a65c66d7c19c8e4d114
dc6dce4a544fdca2df29d5ac0ea9906bdiv16b28748ea4df4d9c2150843fecfba68
01c3ce868d2b3d9bce8da5c1b7e41e5b
fd273fcf5bcad3dfdad3c41bd81ad3e5
f16b1740fad44fb09bfe928bcc527e08

This is the real master!

This is the real master, keep this post for a day to be worshiped by self-righteous people like "wuzhengqing1" and "KK3K2005".

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn