1

我有一种情况试图实现<header>,一个使用字距调整技术的 logotext,桌面跨浏览器兼容。

从安德鲁先生制作的这个简单但非常方便的工具开始(特别感谢),我找到了解决方案。

在修改之前,我有这个<header>部分header.php

...
        <!-- Start Header -->

        <header class="header row no-padding <?php echo $header_style; ?>" data-equal=">.columns" role="banner">

            <div class="small-7 medium-4 columns logo<?php if ($header_style == 'style1') { ?> show-for-large-up<?php } ?>">

                <?php if ($header_style == 'style2') { ?>

                    <a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"

                    title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"

                    rel="home"><?php bloginfo( 'name' ); ?>

                    </a>

                <?php } ?>

            </div>

            <?php if ($header_style != 'style2') { ?>

            <div class="small-7 medium-4 columns logo">

                <?php if ($header_style == 'style1') { ?>

                    <a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"

                    title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"

                    rel="home"><?php bloginfo( 'name' ); ?>

                    </a>

                <?php } ?>

            </div>

            <?php } ?>

            <div class="small-5 <?php if ($header_style == 'style2') { echo 'medium-8'; } else { echo 'medium-4';} ?> columns menu-holder">

                <?php $full_menu_true = ($menu_mobile_toggle_view == 'style2' && $header_style == 'style2');?>

                <?php if ($full_menu_true) { ?>

                    <nav id="full-menu" role="navigation">

                        <?php if ($page_menu) { ?>

                            <?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown  ) ); ?>

                        <?php } else  if(has_nav_menu('nav-menu')) { ?>

                          <?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>

                        <?php } else { ?>

                            <ul class="full-menu">

                                <li><a href="<?php echo get_admin_url().'nav-menus.php'; ?>">Please assign a menu from Appearance -> Menus</a></li>

                            </ul>

                        <?php } ?>

                    </nav>

                <?php } ?>

                <?php if ($header_search != 'off') { do_action( 'thb_quick_search' ); } ?>

                <?php if ($header_cart != 'off') { do_action( 'thb_quick_cart' ); } ?>

                <a href="#" data-target="open-menu" class="mobile-toggle<?php if (!$full_menu_true) { ?> always<?php } ?>">

                    <div>

                        <span></span><span></span><span></span>

                    </div>

                </a>

            </div>

        </header>

        <!-- End Header -->
...

后:

...
        <!-- Start Header -->
    <header class="header row no-padding <?php echo $header_style; ?>" data-equal=">.columns" role="banner">                        
        <div class="row max_width ">
            <div class="small-7 medium-4 columns logo<?php if ($header_style == 'style1') { ?> show-for-large-up<?php } ?>">
                <?php if ($header_style == 'style2') { ?>
                    <div class="small-7 medium-4 columns logo">
                      <span class="logotext-n">n</span>
                      <span class="logotext-e">e</span>
                      <span class="logotext-u">u</span>
                      <span class="logotext-e2">e</span>
                      <span class="logotext-g">g</span>
                      <span class="logotext-r">r</span>
                      <span class="logotext-i">i</span>
                      <span class="logotext-d">d</span>
                    </div>
                <?php } ?>
            </div>          
        </div>              
                <?php if ($header_style != 'style2') { ?>                       
        <div class="row max_width ">            
            <div class="small-7 medium-4 columns logo">
                <?php if ($header_style == 'style1') { ?>
                    <div class="small-7 medium-4 columns logo">
                      <span class="logotext-n">n</span>
                      <span class="logotext-e">e</span>
                      <span class="logotext-u">u</span>
                      <span class="logotext-e2">e</span>
                      <span class="logotext-g">g</span>
                      <span class="logotext-r">r</span>
                      <span class="logotext-i">i</span>
                      <span class="logotext-d">d</span>
                    </div>
                <?php } ?>
            </div>          
        </div>  
    <?php } ?>                      
        <div class="row max_width ">        
            <div class="small-5 <?php if ($header_style == 'style2') { echo 'medium-8'; } else { echo 'medium-4';} ?> columns menu-holder">
                <?php $full_menu_true = ($menu_mobile_toggle_view == 'style2' && $header_style == 'style2');?>
                <?php if ($full_menu_true) { ?>
                    <nav id="full-menu" role="navigation">
                        <?php if ($page_menu) { ?>
                            <?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown  ) ); ?>
                        <?php } else  if(has_nav_menu('nav-menu')) { ?>
                          <?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
                        <?php } else { ?>
                            <ul class="full-menu">
                                <li><a href="<?php echo get_admin_url().'nav-menus.php'; ?>">Please assign a menu from Appearance -> Menus</a></li>
                            </ul>
                        <?php } ?>
                    </nav>
                <?php } ?>
                <?php if ($header_search != 'off') { do_action( 'thb_quick_search' ); } ?>
                <?php if ($header_cart != 'off') { do_action( 'thb_quick_cart' ); } ?>
                <a href="#" data-target="open-menu" class="mobile-toggle<?php if (!$full_menu_true) { ?> always<?php } ?>">
                    <div>
                        <span></span><span></span><span></span>
                    </div>
                </a>
            </div>          
        </div>  
    </header>
    <!-- End Header -->
...

的CSS code

...
.logotext-n {
  color: #f1ecd6;    
  font-family: "arial black", sans-serif;
  font-weight: 900;
  font-size: 210px;
  text-transform: lowercase;
  letter-spacing: -29px;
}

.
.
.

.logotext-d {
  color: #f1ecd6;    
  font-family: "arial black", sans-serif;
  font-weight: 900;
  font-size: 210px;
  text-transform: lowercase;
  letter-spacing: 0;
}
...

在这一点上,我发现 IE/Firefox 与 Chrome 中的字距调整值看起来不同。我已经阅读了关于Media QueryChrome 值显示更正的信息,并且我已经尝试过这个:

...
@media screen and (-webkit-min-device-pixel-ratio:0) { 
    .logotext-n {
      color: #f1ecd6;    
      font-family: "arial black", sans-serif;
      font-weight: 900;
      font-size: 210px;
      text-transform: lowercase;
      letter-spacing: -18px;
          }
}
    .
    .
    .

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    .logotext-d {
      color: #f1ecd6;    
      font-family: "arial black", sans-serif;
      font-weight: 900;
      font-size: 210px;
      text-transform: lowercase;
      letter-spacing: 0;
          }
}
... 

结果在每个浏览器 IE11/Firefox38.0.5/Chrome43.0.2357.124 m 中看起来都应该如此,而且我在 Chrome 控制台中没有任何错误,但是:

作为编码方面的菜鸟,这是一种很好的跨浏览器支持的字距调整技术,还是有任何其他替代方法可以Media Query直接/简短地应用或其他条件?谢谢,

4

1 回答 1

1

有一个 CSSfont-kerning属性。无需将您的徽标文本分成每个字母的元素。

如果你需要自定义字距,你可以让你span的所有字母都有position: relative,并使用 CSS 将它们向左或向右移动。

于 2015-06-11T23:21:27.583 回答