2017-10-05 26 views
-2

我希望左側的主文本(hello)以及屏幕右側的背景文本(加載),但與主文本垂直對齊。將多段落標記放在同一行上

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <link rel="stylesheet" href="load.css"> 
 
    <title>Hello</title> 
 
</head> 
 

 
<body> 
 
    <div class="textContainer"> 
 
    <p class="hello">Hello</p> 
 
    <div class="backgroundInfo"> 
 
     <div class="spinner"></div> 
 
     <p class="notifText">Loading</p> 
 
    </div> 
 
    <div class="loader"></div> 
 
    </div> 
 
</body> 
 

 
</html>

(微調和裝載機是CSS動畫)

回答

0

試試這個:

.hello { 
 
    float: left; 
 
} 
 

 
.notifText{ 
 
    float: right; 
 
} 
 

 
.loader { 
 
    clear: both; 
 
}
<div class="textContainer"> 
 
    <p class="hello">Hello</p> 
 
    <div class="backgroundInfo"> 
 
     <div class="spinner"></div> 
 
     <p class="notifText">Loading</p> 
 
    </div> 
 
    <div class="loader"></div> 
 
</div>

+0

你好有一個200px的字體大小,我希望notifText遠遠小於那個,任何想法我怎麼可以將它與中心對齊.hello? – Michael

0

爲了使這兩段在同一顯示線,只需使用:

p{ 
    float: left; 
} 

下一步將是CSS元素和cointainer的寬度。