简体   繁体   English

Bootstrap移动对齐vs桌面

[英]Bootstrap Mobile Alignment vs Desktop

Basically, I am coding a simple page and on desktop, it all aligns just fine. 基本上,我正在编写一个简单的页面,在桌面上,一切都很好。 When switched over to mobile it appears very differently. 切换到移动设备后,其外观将大为不同。 I will include screenshots to show what I mean. 我将包括截图以显示我的意思。 I have tested this on Nexus 5, iPhone 6, iPad Air and two different desktop monitors (21in + 17in). 我已经在Nexus 5,iPhone 6,iPad Air和两个不同的台式机显示器(21英寸+ 17英寸)上对此进行了测试。

How would I go about fixing this exactly? 我将如何确切地解决此问题? I am not very advanced in bootstrap but I couldn't find anything in the documentation about mobile. 我在引导程序方面不是很高级,但是在有关移动的文档中找不到任何东西。

Also, the alignment of things and their position changes based on size of monitor. 此外,事物的对齐方式及其位置也会根据监视器的大小而变化。 Even if I zoom out it will change the position of things and make it look weird. 即使缩小,它也会改变事物的位置并使它看起来很奇怪。

I guess what I'm wondering is how to make this page more repsonsive! 我想我想知道的是如何使此页面更具响应性!

桌面移动

Here is the code for the section: 这是该部分的代码:

    <div class="well" style="height:12%;width:75%;">
        <div class="col-md-10">
            Testing12332<br /><br /><a class="link" href="view.php?id=27"><b>Testingthis</b> - 0 seconds</a>
        </div>
        <div class="col-md-2">
            <form action="like.php?id=27" method="POST" style="margin-bottom:0px;margin-top:-8%;">
                <button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">&#9650</button><br />
                <input type="hidden" name="id" value="27">
            </form>
            <div class="well" style="padding:0px;margin-bottom:0px;">
                0
            </div>
            <form action="dislike.php?id=27" method="POST">
                <button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">&#9660;</button><br />
                <input type="hidden" name="id" value="27">
            </form>
        </div>
    </div>

Let me know if more information is needed! 让我知道是否需要更多信息! I tried to provide as much as possible! 我试图提供尽可能多的东西! Also, yes, I am using Bootswatch (Flatly) if that makes a difference. 另外,是的,如果有区别的话,我正在使用Bootswatch(Flatly)。

Edit: All of the code is here --> http://pastebin.com/AvYEkDNN 编辑:所有代码都在这里-> http://pastebin.com/AvYEkDNN

Sorry for the format being messed up, a lot of it is output with PHP and messed up the format in each loop. 抱歉,格式混乱,很多都是PHP输出的,并且在每个循环中都弄乱了格式。

Here's a link to your complete HTML. 这是完整HTML的链接。 http://pastebin.com/ZCvDzz3b The only other thing you need to do is create an external stylesheet if you don't already have one called style.css and then add this code at the bottom of this sheet. http://pastebin.com/ZCvDzz3b您还需要做的另一件事是创建一个外部样式表(如果您还没有一个名为style.css的样式表),然后在此表的底部添加此代码。 Make sure your style.css is placed in the same location as your index file. 确保您的style.css与索引文件位于同一位置。

@media (min-width:768px) {
        .well {width:75%!important;
                height:22%!important;
        }
    }

OK, I have found the issue thank you to your comment 好的,我发现了这个问题,谢谢您的评论

First of all, do NOT use inline styling. 首先,不要使用内联样式。 It usually means problems and quite rarely a solution. 这通常意味着问题,很少解决。

With that in mind, get rid of this: 考虑到这一点,摆脱这一点:

<form action="like.php?id=27" method="POST" style="margin-bottom:0px;margin-top:-8%;">

and replace it by 并替换为

<form action="like.php?id=27" method="POST" class="my-custom-form">

this will allow you to re-use that style every time. 这样您就可以每次重复使用该样式。

Now you can do something like this by simply adding some EXTERNAL CSS: 现在,您只需添加一些EXTERNAL CSS即可执行以下操作:

.my-custom-form{margin-bottom:0px;margin-top:-8%;}
/** add some styling for small devices **/
@media handheld, only screen and (max-width: 767px) {
.my-custom-form{margin-bottom:0px;margin-top:1% /* or whatever, just not a negative value */;}
}

and it will fix your issue 它将解决您的问题

EDIT: 编辑:

Besides the above, clean your code like this: 除上述内容外,按以下方式清理您的代码:

<div class="well row-fluid">
    <div class="col-md-10">testingthis
        <br />
        <br /><a class="link" href="view.php?id=28"><b>Anonymous</b> - 27 minutes ago</a>

    </div>
    <div class="col-md-2">
        <form action="like.php?id=28" method="POST" class="my-form">
            <button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">&#9650</button>
            <br />
            <input type="hidden" name="id" value="28" />
        </form>
        <div class="number">-1</div>
        <form action="dislike.php?id=28" method="POST">
            <button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">&#9660;</button>
            <br />
            <input type="hidden" name="id" value="28" />
        </form>
    </div>
    <div class="clear clearfix"></div>
</div>

and also get rid of your element. 并摆脱你的元素。 With all these changes (plus any additional visual adjustment you may need), it will work on all sizes 经过所有这些更改(加上您可能需要的任何其他视觉调整),它将适用于所有尺寸

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

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