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

WBOY
Release: 2016-06-24 12:20:42
Original
1288 people have browsed it

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


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>
Copy after login

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>
Copy after login


I forgot to write the style, so I added

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






span
div
>


 
  
;



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>
Copy after login
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.

play:inline-block ;">div 

 





span

div



This is the real master!





span

div



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".

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template