gpt4 book ai didi

CSS 媒体查询 : to second row depending on screen width

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:08 25 4
gpt4 key购买 nike

我有一个包含以下元素的 div

<div>
<a class="postLink" href="{{post.authorLink}}" target="_blank">{{post.author}}</a>
<span class="">Published: {{ post.published}}</span>
<a class="postLink" href="{{post.link}}" target="_blank">View More</a>
</div>

通常呈现为:

{{post.author}}   Published: {{ post.published}}   View More

当屏幕小于 760px 时,如何将所有链接移动到第二行?

Published: {{ post.published}}   
{{post.author}} View More

最佳答案

您可以在容器上使用相对位置,然后在媒体查询中使用绝对位置作为跨度。但我觉得这种方式更有趣:

.postInfo a {
margin-right: 20px;
}
.postPublished::after {
content: attr(data-published);
display: inline-block;
margin-right: 20px;
}

@media (max-width: 780px) {
.postPublished::after {
display: none;
}
.postPublished::before {
content: attr(data-published);
display: block;
}
}
<div class="postInfo">
<span class="postPublished" data-published="Published: {{ post.published}}">
<a class="postLink" href="{{post.authorLink}}" target="_blank">{{post.author}}</a>
</span>
<a class="postLink" href="{{post.link}}" target="_blank">View More</a>
</div>

查一下on Fiddle .

关于CSS 媒体查询 : to second row depending on screen width,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37231674/

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