【发布时间】:2017-12-15 23:59:44
【问题描述】:
我需要将徽标水平和垂直居中居中,因此我使用了 bootstrap 中的 .table 和 .table-cell。问题是,虽然图像在中心完全对齐,但 .table-cell 会达到其父级长度的 100%,如果包裹在 <a href> 中,则整个宽度都是可点击的。
代码:
<div class="header-content table">
<div class=" table-cell">
<?php
if( function_exists( 'the_custom_logo' ) ) {
if(has_custom_logo()) {
$custom_logo_id = get_theme_mod( 'custom_logo' );
$image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
echo '<a href="'.get_home_url().'"><div class="harmony-logo background-image" style="background-image: url('.$image[0].');">';
echo '</div></a>';
} else {
echo '<h1 class="site-title"><?php bloginfo("name"); ?></h1>';
}
} ?>
</div><!-- .table-cell -->
</div><!-- .header-content -->
【问题讨论】:
标签: html css wordpress css-tables