gpt4 book ai didi

javascript - 如何将 CSS 添加到链接预览?

转载 作者:行者123 更新时间:2023-11-28 17:03:32 26 4
gpt4 key购买 nike

我有这个 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>

看起来像这样:

enter image description here

我想添加 CSS 使其看起来更像 Facebook 帖子,但我不确定从哪里开始。

enter image description here

我的想法是这是一篇新闻文章的预览,我会在一篇讨论它的博客文章中链接它。这是我用来生成它的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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com