我有一個聊天室,我建立在節點js,HTML和CSS,我將消息附加到一個div和樣式的消息用CSS所以我的問題是什麼定位這些元素的最佳方式就像個人資料圖片,名稱,日期和消息什麼是定位元素內的元素
這裏是我當前的樣式我對這些並不滿意,因爲如果您在開發工具中查看它們,您會看到跨度或不管是更大或比實際更小的元素應該是我覺得
here是鏈接到我的網站,以便您可以查看開發工具
這裏是我曾嘗試我喜歡的外觀,但這個困擾我,使我認爲會有其他圖形錯誤設備
#message-container {
word-wrap: break-word;
position: relative;
padding: 0px;
margin: 0px;
color: black;
}
.chat-room-profilePic img {
position: relative;
left: 10px;
height: 50px;
width: 50px;
border-radius: 25px;
margin-bottom: 0px;
padding: 0px;
margin: 0px;
}
.chat-room-message {
color: black;
position: relative;
left: 52px;
top: 10px;
}
.chat-room-date {
position: relative;
font-size: 12px;
top: 0px;
margin-bottom: 0px;
color: cadetblue;
}
.message-info {
position: relative;
top: -32px;
left: 20px;
}
能有人爲請幫助我,或告訴我什麼我做錯了
這並不直接回答你的問題,但我會建議學習如何使用CSS flexbox。 Flexbox是動態佈局的規範。 [Stackoverflow文檔](http://stackoverflow.com/documentation/css/445/flexible-box-layout-flexbox#t=201702220104341168087)和[css技巧](https://css-tricks.com/snippets/css/a-guide-to-flexbox /)有一個體面的教程。 –