我目前正在研究一種方法來顯示電影列表,包括封面縮略圖,標題和發佈日期。整個事情對於短小的標題來說工作得很好,但如果涉及更長的標題,整個事情會變得混亂。將縮略圖對齊文字(2行)
你能告訴我如何將文本與圖像對齊,結果如下圖所示:
我很感謝各種提示。
代碼(在「整版」 - 模式運行段的最佳體驗)
header {
\t background-color: grey;
\t margin: 3px;
\t padding-left: 7px;
}
header > h2 {
\t display: inline-block;
}
#info {
\t padding-left: 5px;
\t margin: 1px;
\t float: left;
\t width: 69%;
}
#result {
\t float: right;
\t width: 29%;
\t margin:1px;
}
.pillLink > h {
\t display: inline-block;
}
.pillLink {
\t display: inline-block;
\t padding-left: 20px;
}
.pill > #cover {
\t height: 100px;
\t outline: 2px solid white;
}
.pill {
\t
\t padding: 7px;
\t margin: 10px;
\t background-color: silver;
\t -webkit-border-radius: 7px!important;
\t -moz-border-radius: 7px!important;
\t border-radius: 7px!important;
\t border: 1px solid grey
}
<html>
\t <head>
\t \t <!-- Latest compiled and minified CSS -->
\t \t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
\t \t <link rel="stylesheet" type="text/css" href="pills_style.css">
\t </head>
\t
\t <body>
\t
\t <div id="info">
\t
\t </div>
\t
\t <div id="result">
\t <h2>similar results</h2>
\t \t <div>
\t \t \t <div class="pill">
\t \t \t \t <img src="http://3dprint.com/wp-content/uploads/2014/11/int3.jpg" id="cover">
\t \t \t \t <a href="http://www.imdb.com/title/tt0816692" class="pillLink"><h3>Very Long Sample Text 4: A new Hope Extended Cut</h3></a>
\t \t \t \t <span>(2014)</span>
\t \t \t </div>
\t \t \t
\t \t \t <div class="pill">
\t \t \t \t <img src="http://3dprint.com/wp-content/uploads/2014/11/int3.jpg" id="cover">
\t \t \t \t <a href="http://www.imdb.com/title/tt0816692" class="pillLink"><h3>Very Long Sample Text 7: The Force Awakens 3D</h3></a>
\t \t \t \t <span>(2014)</span>
\t \t \t </div>
\t \t \t
\t \t \t <div class="pill">
\t \t \t \t <img src="http://3dprint.com/wp-content/uploads/2014/11/int3.jpg" id="cover">
\t \t \t \t <a href="http://www.imdb.com/title/tt0816692" class="pillLink"><h3>Short Sample Text 10: XXS</h3></a>
\t \t \t \t <span>(2014)</span>
\t \t \t </div>
\t \t </div>
\t </div>
\t
\t
\t </body>
</html>
不應該在你的CSS的'.pillLink> h'是'.pillLink> h3'? – xkcd149
@ xkcd149謝謝,我會修復它。 – JohnDizzle