gpt4 book ai didi

css - 跨浏览器字距适当调整技术

转载 作者:行者123 更新时间:2023-11-28 17:03:36 24 4
gpt4 key购买 nike

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

从这个简单但非常方便的开始 tool由 Mr.Andrew 制作(特别感谢),我找到了解决方案。

修改前我有这个<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 Query我已经为 Chrome 值显示校正尝试了这个:

...
@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;
}
}
...

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

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

最佳答案

有一个 CSS font-kerning 属性。无需将 Logo 文本分成每个字母的元素。

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

关于css - 跨浏览器字距适当调整技术,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30788750/

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