我有这个 HTML:
<a href="http://waterfordwhispersnews.com/2017/01/19/im-the-only-one-creating-jobs-around-here-local-drug-dealer-slams-government/#FB-Comments" class="link-preview" target="_blank" rel="nofollow">
<div class="link-area">
<div class="og-image">
<a href="http://waterfordwhispersnews.com/wp-content/uploads/2017/01/grater.jpg" title="" class="fancybox" rel="article0">
<img src="http://waterfordwhispersnews.com/wp-content/uploads/2017/01/grater.jpg">
</a>
</div>
<div class="descriptions">
<div class="og-title">
“I’m The Only One Creating Jobs Around Here” Local Drug Dealer Slams Government
</div>
<div class="og-description">
WATERFORD drug dealer Richie 'The Grater' Harrington has today slammed the Irish government for ignoring the young people in his council est…
</div>
</div>
</div>
</a>
看起来像这样:
我想添加 CSS 使其看起来更像 Facebook 帖子,但我不确定从哪里开始。
我的想法是这是一篇新闻文章的预览,我会在一篇讨论它的博客文章中链接它。这是我用来生成它的hexo插件。 https://github.com/minamo173/hexo-tag-link-preview
至少,它需要被装箱。截至目前,它只是继承典型帖子的链接和图像的样式。
最佳答案
这里有一个建议,你可以如何做,添加虚线边框,标题上更大的字体 + anchor 和标题上的一些填充,使它看起来很好:)
还有一个小技巧 (display: table-caption
) 让文本换行并适合图像。
我还删除了内部链接 a
,因为它对嵌套 anchor 无效。
堆栈片段
a.link-preview {
display: inline-block;
border: 2px dotted black;
padding: 5px;
}
a.link-preview .link-area {
display: table-caption; /* make text wrap under image */
}
a.link-preview .link-area .og-title {
font-size: 22px;
padding-bottom: 15px;
}
<a href="http://waterfordwhispersnews.com/2017/01/19/im-the-only-one-creating-jobs-around-here-local-drug-dealer-slams-government/#FB-Comments" class="link-preview" target="_blank" rel="nofollow">
<div class="link-area">
<div class="og-image">
<img src="http://waterfordwhispersnews.com/wp-content/uploads/2017/01/grater.jpg">
</div>
<div class="descriptions">
<div class="og-title">
“I’m The Only One Creating Jobs Around Here” Local Drug Dealer Slams Government
</div>
<div class="og-description">
WATERFORD drug dealer Richie 'The Grater' Harrington has today slammed the Irish government for ignoring the young people in his council est…
</div>
</div>
</div>
</a>
关于javascript - 如何将 CSS 添加到链接预览?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51227692/