[問題] 要怎麼讓兩個div相鄰呢

看板Web_Design作者 (又來了)時間15年前 (2010/09/09 12:46), 編輯推噓7(704)
留言11則, 7人參與, 最新討論串1/1
最近剛學div標籤 遇到瓶頸 就是我一連串標籤寫下來 想讓兩個標籤左右相鄰 但是它們怎麼試都會變上下 以下是html的語法 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文件</title> <style type="text/css"> <!-- @import url("css.css"); body { background-color: #333333; } --> </style> </head> <body> <div class="top">123</div> <div class="medd">456</div> </body> </html> CSS語法是 @charset "utf-8"; /* CSS Document */ .top { width: 20px; padding-left: 300px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; color: #FF0000; } .medd { font-size: 12px; color: #00FF00; height: 20px; width: 100px; } 已經試了整個早上了 我想應該是有個簡單的概念沒弄通吧 麻煩大家指點我一下吧 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.45.186.47

09/09 12:54, , 1F
設 float:left;
09/09 12:54, 1F

09/09 12:55, , 2F
那請問如果我有四個要排的話呢?
09/09 12:55, 2F

09/09 13:00, , 3F
四個都設 但是你要注意總寬不能超過最外圍寬度
09/09 13:00, 3F

09/09 14:03, , 4F
試出來了!感謝!!!!
09/09 14:03, 4F

09/09 17:57, , 5F
推一樓正解
09/09 17:57, 5F

09/10 12:55, , 6F
用float不是很好 display:inline-block;才符合定義
09/10 12:55, 6F

09/10 12:56, , 7F
ie會有問題 不過可以hack
09/10 12:56, 7F

09/10 21:31, , 8F
想請教樓上 ie要怎麼hack呀?
09/10 21:31, 8F

09/11 19:42, , 9F
09/11 19:42, 9F

09/11 20:20, , 10F
感謝!! ie原來要先hasLayout=ture 再下inline~
09/11 20:20, 10F

10/08 15:02, , 11F
<span></span> 就是不會換行的 <div> 標籤
10/08 15:02, 11F
文章代碼(AID): #1CY6R2Sy (Web_Design)