简体   繁体   中英

Align two elements on the same line

I am trying to align two different <p> elements on the same line. I got it to work but it completely messed up my logo. The two <p> elements are the "TEST"s you see on either side of the logo.

The code for the alignment is this : HTML CODE

<div id="logo" class="container">
<div align="center">        
    <img src="images/Logo.png" align="middle" alt="logo" height="105" width"105">
</div>
<div align="center">
 <p style="color:white;" id="countr">test</p> 
 <p style="color:white;" id="countl">test</p> 
</div>
    <h1 style="left:50px;"><span class="icon icon-size"></span><a href="#">Clubbed<span> In</span></a></h1>
<div align="center">
    <h2 class="motto" style="color : white">Connect. Communicate. Lead.</h2>
</div>

CSS

#countr{display:inline-block;float:right;} 
#countl{display:inline-block;left:35px;float:left;}

屏幕截图

Your <p> are:

<p style="color:white;" id="countr">test</p> 
<p style="color:white;" id="countl">test</p> 

Use this:

#countr, #countl {
 display: inline-block;
}

If doesn't work, then you can use this for countr

#countr {
float: left;
}

This will make them float inline!

If I were you I would get rid of ALL of the div align="center"s from your HTML, just have every element without them. And then the float should work better. Even better, you might just want to position: absolute; each of the TEST texts

FIDDLE

<div>
  <p style="color:black;float:left;" id="countr">test</p> 
 <p style="color:black;float:right;" id="countl">test</p> 
</div>
    <h1 align="center" style="margin:0 auto;clear:both;"><span class="icon icon-size"></span><a href="#">Clubbed<span> In</span></a></h1>
<div align="center">
    <h2 class="motto" style="color : black">Connect. Communicate. Lead.</h2>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM