简体   繁体   English

引导容器,图像丢失对齐

[英]Bootstrap container, image loses alignment

The page i've made so far can be viewed here . 我到目前为止做的页面可以在这里查看。

And the HTML here: http://jsbin.com/fujozekoqama/1/edit?html 此处的HTML: http//jsbin.com/fujozekoqama/1/edit? html

Notice what happens when you make the browser window smaller . 注意缩小浏览器窗口会发生什么。

Why does the image lose alignment to the menu if they are in the same container? 如果图像在同一容器中,为什么图像与菜单失去对齐?

Here are pictures of what I'm seeing: 以下是我所看到的图片:

aligned : http://i.imgur.com/aZUkVIR.png 对齐http : //i.imgur.com/aZUkVIR.png

unaligned : http://i.imgur.com/o0Mdg4J.png 未对齐http : //i.imgur.com/o0Mdg4J.png

You need to remove this from your styles, because it's affecting the responsiveness of the layout: 您需要从样式中删除它,因为它影响布局的响应性:

.container .navbar-default {
    min-width:640px;
    width:640px;
    }

and add the .img-responsive class to your image, like this: 并将.img-responsive类添加到图像中,如下所示:

<img class="logo img-responsive" src="http://placehold.it/350x75">

and then close the first .container div, which is open 然后关闭打开的第一个.container div

with these tiny changes, it will work just as you want, and your layout will be responsive (which is the whole idea after Bootstrap after all). 通过这些微小的更改,它将按您希望的那样工作,并且您的布局将具有响应性(毕竟这是Bootstrap之后的全部想法)。

If you need some min-width, add it in the .container class, not the inner elements. 如果需要一些最小宽度,请将其添加到.container类中,而不是内部元素中。 For this purpose, it's always a good idea to add an additional class to re-usable classes, for example <div class="container myMinWidth"> so you can target the .myMinWidth class without affecting the .container class, which you will need to use everywhere in Bootstrap. 为此,最好在可重用的类中添加一个附加类,例如<div class="container myMinWidth">以便您可以定位.myMinWidth类而不影响.container类,这是您所需要的在Bootstrap的任何地方使用。

And finally, unless you really need it (which you probably don't), avoid using fixed sizes in responsive layouts, if needed, try to use percentages, but make sure to check Bootstrap docs, because there are lots of built-in classes like img-responsive that will adjust your images like in your present situation 最后,除非确实需要(可能不需要),否则避免在响应式布局中使用固定大小,如果需要,请尝试使用百分比,但请确保检查Bootstrap文档,因为其中有很多内置类像img-responsive response一样,可以像现在这样调整您的图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM