gpt4 book ai didi

css - 主页上的不同 CSS

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

我的样式表中有这段代码:

#social-icons {
width:100%;
}
#social-icons li {
float:right;
display: inline;
list-style-type:none;
padding: 10px 10px 10px 10px;
width:50px;
height:50px;
text-decoration: none;
}

我希望所有页面上的 #social-icons li 都为 float:left,主页除外。

最佳答案

在你的主题中header.php文件,在 </head> 之前标记,只需放入此代码:

<?php
if(!is_homepage())
{
?>
<style type="text/css">
#social-icons li {float:left}
</style>
<?php
}
?>

如果你不想碰你的主题,你可以使用wp_head action hook .

在 Bruno Toffolo 的评论之后

如果您不喜欢内联 css,您可以将特定于主页的 css 规则放入另一个 css 文件,如 homepage.css,然后使用 is_homepage() 条件标记将此 css 文件加入队列。

<?php
if(!is_homepage())
{
wp_enqueue_style(...);
}
?>

关于css - 主页上的不同 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29381556/

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