简体   繁体   English

更改视口以更改div宽度

[英]Change viewport on changing a div width

I have a form designer in my app and for the purpose of user experience I need to give the user this ability to change the viewport and see how the form would looks like in the actual form. 我的应用程序中有一个表单设计器,为了用户体验,我需要为用户提供更改视口的能力,并查看表单在实际表单中的外观。

I am using bootstrap 3 to shape the form and using the col and row classes to manage the layouts. 我正在使用bootstrap 3来整形表单,并使用col和row类来管理布局。 there is 4 button in the form with the icon of the viewport such as Desktop , Tablet , Tablet-Horizontal , Mobile. 表单中有4个按钮,带有视口图标,如桌面,平板电脑,平板电脑,水平,移动。

when the user click on those buttons I add the desired class to my container div and resize it with the width property. 当用户点击这些按钮时,我将所需的类添加到我的容器div中,并使用width属性调整其大小。 but when I bootstrap does not detect that and don't respond to the div changes because it works with window width ( like media queries ). 但是当我的bootstrap没有检测到并且不响应div更改时,因为它适用于窗口宽度(如媒体查询)。

here is the css: 这是css:

.edit__container {
    &.container--lg {
        width: 100%;
    }

    &.container--md {
        width: 80%;
    }

    &.container--sm {
        width: 60%;
    }

    &.container--xs {
        width: 30%;
    }
}

what I tried is change the viewport meta tag with javascript and set the width to something like 200 or more, but not working. 我尝试的是用javascript更改视口元标记,并将宽度设置为200或更多,但不起作用。

another try was to change the window width with jquery, but no luck. 另一个尝试是用jquery改变窗口宽度,但没有运气。

just so remember, i cannot use iframe inside my form. 请记住,我不能在我的表格中使用iframe。

You can add some class to your parent and override the bootstrap classes within that scope. 您可以向父级添加一些类,并覆盖该范围内的引导类。
For example: 例如:

.edit__container {

    &.container--xs {
        width: 30%;


        @for $i from 1 to 12 {
        .col-md-#{$i} {
                width:100%;
            }
        }

    }
}

Do it for col-sm , col-lg and so on... col-smcol-lg等做它...

尝试添加!important以覆盖引导程序宽度,例如使用jQuery

$("Selector").css("cssText", "width: size% !important;");

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

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