0
我在我的頭文件中有一個搜索欄,它需要水平居中並稍微高於頁眉底部。我能夠通過使用製作搜索欄響應的問題
display: flex;
justify-content: center;
align-items: center;
我現在有是,儘管當你使窗口小水平很敏感,這是一個總的混亂,當你垂直調整窗口大小的問題,以實現這一目標。我很確定這是因爲我使用了margin-top:350px;設置垂直位置。我也寧願不使用柔性顯示器,因爲它還不被支持。下面是一個截圖,它看起來是否正常,以及垂直改變視圖時的樣子。還有關於它的代碼。如果有人能幫我弄清楚如何讓搜索欄垂直響應,那會很棒!
HTML:
<div class="outcont">
<div id="top" class="header">
<div class="wrap">
<div class="col1"><a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?> - Return to the homepage"><img class="logoi" src="<?php bloginfo('stylesheet_directory'); ?>/images/main-logo.png" alt="<?php bloginfo('name'); ?> Logo" /></a></div>
<div class="col2"><?php wp_nav_menu(array('menu' => 'global-nav', 'container' => '')); ?></div>
</div>
<?php get_search_form(); ?>
</div>
CSS :
#searchform div {
shadow: 4px 7px 4px #000000;
margin-top: 350px;
display: flex;
justify-content: center;
align-items: center;
}
#searchform .text {
font-family: 'Merriweather';
padding-left: 35px;
height: 75px;
width: 600px;
font-size: 220%;
color: #B7B7B7;
border-radius: 50px;
background: white url('images/search-img.png') no-repeat;
background-position: 96% center;
}
#searchform .text:focus {
background-image: none;
}
#searchform .text img {
margin-right: 25px;
}
Flex受所有瀏覽器中95%的支持。 http://caniuse.com/#feat=flexbox – Thomas