標籤:font class ble youdao 20px body com 技術 osi
【問題描述】左側文字,右側圖片。 左側上方為廣告描述,下方為“廣告 ×”。 上方廣告描述可能為一行,兩行,三行;下方“廣告” 和 “ ×” 的相對位置不同,。
在看參考代碼前,可自己先試著寫寫。
=====================================
【參考代碼】
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>廣告</title> <style> .section { line-height: 40px; font-size: 15px; text-align: justify; margin: 10px 0; position: relative; } .relative { position: relative; } .clear-fix:after { clear: both; content: ""; display: block; } .right-img { float: right; width: 150px; height: 120px; } .left-txt { margin-right: 150px; } .left-txt .p-txt { min-height: 80px; } .right-img img { width: 100%; height: 100%; } .pull-right{ float: right; } </style></head><body> <div class="section clear-fix"> <div class="right-img"> <img src="head.jpg" alt="頭像"> </div> <div class="left-txt"> <div class="p-txt">去哪兒旅行頻道在旅遊攻略。</div> </div> <span class="relative">廣告</span> <span class="pull-right">×</span> </div> <div class="section clear-fix"> <div class="right-img"> <img src="head.jpg" alt="頭像"> </div> <div class="left-txt"> <div class="p-txt">去哪兒旅行頻道在旅遊攻略。去哪兒旅行頻道在旅遊攻略。</div> </div> <span class="relative">廣告</span> <span class="pull-right">×</span> </div> <div class="section clear-fix"> <div class="right-img"> <img src="head.jpg" alt="頭像"> </div> <div class="left-txt"> <div class="p-txt">去哪兒旅行頻道在旅遊攻略。去哪兒旅行頻道在旅遊攻略。攻略</div> </div> <span class="relative">廣告</span> <span class="pull-right">×</span> </div></body></html>
【CSS基礎】廣告位兩欄布局