我想在计算机/大型显示器上将类别显示为导航菜单,但如果有人从移动网站浏览该网站,则将其隐藏。
你能看看我的代码并告诉我我错过了什么吗?
来自样式文件:
样式.css
@media only screen
and (min-width : 999px) {
.categories {
background-color: #1e73be;
color: #fff;
width: 220px;
left: 0px;
top: 150px;
float: left;
position: absolute;
display: table;
overflow: scroll;
text-align: center;
};
...
@media only screen
and (max-device-width: 998px) {
.categories { display: none; }
#category { display: none; }
}
类别.php
<?php
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '<h4><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "Νέα για: %s" ), $category->name ) . '" ' . '><div id="category">' . $category->name.'</div></a></h4>';
}
?>
单个.php
<nav class="categories">
<?php include(TEMPLATEPATH . '/inc/category.php'); ?>
</nav>
感谢您的宝贵时间!欢迎对我的代码进行任何其他更改。
最佳答案
试试这个:
@media(最大宽度:998px)
代替
@media 仅屏幕
和(最大设备宽度:998px)
关于php - 用 CSS 隐藏代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25704475/