How to center an image when the navigation bar shrinks?
P粉647504283
P粉647504283 2023-08-18 11:05:33
0
1
451
<p>I am using a template to build the website (https://github.com/learning-zone/website-templates/tree/master/victory-educational-institution-free-html5-bootstrap-template), the original The navigation bar looks like this: </p> <p>Before shrinking: Navigation bar</p> <p>After minification: Navigation bar</p> <p>I changed the logo to my logo. Since my logo is smaller vertically, I changed the margins from 10px to 20px</p> <pre class="brush:php;toolbar:false;">.logo { width: 40%; margin: 20px 0px 20px 0; }</pre> <p>It looks centered: Navigation bar</p> <p>But when I scroll down the page, the navigation bar shrinks and my logo doesn't stay vertically centered. It moves up. Navigation bar</p> <p>I tried to fix the css, but it didn’t work</p> <pre class="brush:php;toolbar:false;">.logo { display: flex; justify-content: center; align-items: center; width: 40%; margin: 20px 0px 20px 0; }</pre> <p>This is the html code of the logo</p> <pre class="brush:php;toolbar:false;"><div class="logo smooth-scroll"> <a href="#banner"><img id="logo" src="images/boxinghub.png" alt="boxinghub logo"></a> </div></pre> <p>The code in the css controls the position when zoomed out, but even if I add .logo or #logo, it doesn't help. </p> <pre class="brush:php;toolbar:false;">@media (min-width:768px) { .fixed-header-on .navbar-default .navbar-nav > li > a { padding-top: 20px; padding-bottom: 20px; } }</pre> <p>Thanks in advance for your help! </p>
P粉647504283
P粉647504283

reply all(1)
P粉898049562

You can use the background method Like background-position:center

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!