【问题标题】:The Header overflows about 20pxHeader 溢出约 20px
【发布时间】:2017-07-29 01:42:31
【问题描述】:

我正在开发一个基于 CMS WordPress 的学校项目(餐厅网站),但我的标题有问题,大约 20-19 像素溢出,我不知道如何修复它。

我无法为标题设置固定大小,因为导航菜单无法正常工作,min-height 也无法正常工作。

有人可以帮我解决这个问题吗?我没有太多时间完成这个项目,我还有很多工作要做:) 网址是http://restaurant.g6.cz/menu/

Image shows the problem here /标题/

    header .heading {
      display: block;   
      width: 100%;
      height: 300px;    
      background-repeat: no-repeat;}   


    .slider{
      display: block;
      width: 100%;
      height: 300px;    
      position: absolute;
    }

      /*Horizontal menu*/

    header nav{
        width: 100%;
        background-color: #232323;
        display: table;

    }

    header nav ul{
        background-color: #232323;
        overflow:hidden;
        color:white;
        padding:0px;
        text-align:center;
        list-style-type: none;
        margin:0px;
        transition: max-height 0.4s;
        -webkit-transition: max-height 0.4s;
        -ms-transition: max-height 0.4s;
        -moz-transition: max-height 0.4s;
        -o-transition: max-height 0.4s;
    }

    header nav ul li{
        display:table-cell;
        padding: 15px 0px 15px 0px;
        border-right: 1px;
        border-right-style:solid;
        border-right-color: #333333;
        vertical-align: middle;
        font-weight: bold;


        }

    header nav ul li a{
        font-size: 100%;
        text-decoration: none;
        color: white;
        padding: 15px 20px 16px 20px;
    }

    header nav ul li:hover{
    background-color: #171717;
    }

    header nav ul li a:hover {
    color: #DDAF4D;
    }

    header nav ul li.current-menu-item {
    background: #171717;
    }

    header nav ul li.current-menu-item a {
    color: #DDAF4D;
    }


    .menupozmenseni {
    width: 100%;
    background-color: #171717;
    text-align:left;
    box-sizing: border-box;
    /*padding: 15px 10px;   */
    height: 49px;
    cursor: pointer;
    color: white;
    display:none;
    background-image:url(obrazky/menu.png);
    background-repeat:no-repeat;
    background-position: center;
    }

    @media screen and (max-width: 968px) {

    header nav ul{
        max-height: 0px;
    }

    header nav ul li {
    box-sizing:border-box;
    width: 100%;
    padding: 0px;
    display:block;
    }

    header nav ul li a{
    display:block;
    margin: 0px;
    padding: 15px 0px 16px 0px;
    }

    .menupozmenseni{
        display:block;

        }

    .skryteprvkymenu{
        max-height: 450px; 
        -webkit-transition: max-height 0.8s;
        -ms-transition: max-height 0.8s;
        -moz-transition: max-height 0.8s;
        -o-transition: max-height 0.8s;
        }


    }
    </style>





    <header>


        <div class="heading">
                <div class="slider">

      <?php if (is_page($page = 'menu' )){ ?>
      <?php echo do_shortcode('[smartslider3 slider=6]'); ?>

      <?php }   elseif (is_page($page = 'vinny-listek' )){ ?>
      <?php echo do_shortcode('[smartslider3 slider=7]'); ?>

      <?php }else{ ?>
      <?php echo do_shortcode('[smartslider3 slider=5]'); ?>

      <?php } ?>

      </div>
      <div class="site-branding">
                <?php if ( is_front_page() || is_home() ) : ?>
                    <div class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></div>
                <?php else : ?>
                    <div class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></div>
                <?php endif;

                $description = get_bloginfo( 'description', 'display' );
                if ( $description || is_customize_preview() ) : ?>
                    <div class="site-description"><?php echo $description; ?></div>
                <?php endif; ?>
           </div>

      <div class="nadpis">
      <a href="<?php the_permalink();?>"><?php the_title();?></a>
      </div>


        </div>

        <nav class="site-nav">

            <?php

            $args = array(
                "theme_location" => "primary"
            );

            ?>

            <?php
                wp_nav_menu($args);
            ?>

    <div class="menupozmenseni"></div>     

        </nav>

    <script>
    $( ".menupozmenseni" ).on( "click", function() {
        $("header nav ul").toggleClass("skryteprvkymenu");
    });
</script>

    </header>

【问题讨论】:

  • 你能提供你的代码吗?
  • 如果你通过检查器查看你的元素,在你关闭标题标签之前,你的脚本标签后面有一些不可见的编码字符,这个不可见的字符正在创建空格
  • Sweta Parmar:如果你真的想要我可以,我觉得最好在这里放一个链接 :) PhilS:你说得对,我现在可以看到它,因为网站是响应式的,当您调整浏览器窗口的大小时,您可以看到隐藏的元素。如果没有空白空间,我怎么能以不同的方式做到这一点? :)

标签: php html css wordpress header


【解决方案1】:

如果您在标题中看到检查器,您会发现这个字符串 "&amp;#65279"。查看屏幕截图以亲自查看。这就是导致额外空白的原因,删除它就可以了!

【讨论】:

  • 谢谢 :) 它在 PSPad 中不可见,但我下载了 Adob​​e Dreamweaver 试用版,它在那里像小红点一样可见,所以我删除了这一点,它解决了我的问题,但也许每个人都可以解决保存没有 BOM 的 UTF-8 文件时会出现此问题 :)
猜你喜欢
  • 2014-05-28
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多