简体   繁体   English

如何根据容器更改元素的宽度?

[英]How to change the width of elements based on container?

Hi in my website I have one container with Registration form elements. 您好,我的网站中有一个包含“注册”表单元素的容器。 Now I want to change the size of labels, Text fields and button based on the container size. 现在,我想根据容器大小更改标签,文本字段和按钮的大小。

My requirement is The textboxes should be on the right of the labels (and expand up to 40px before the right border of the grey container - 40px is the container's padding anyway) when the width of the screen is >=1024px . 我的要求是,当屏幕的宽度> = 1024px时,文本框应位于标签的右侧(并在灰色容器的右边界之前扩展到40px-无论如何,该容器的填充为40px)。 If the width of the screen is <1024, the textboxes should be under the labels and their width should be as long as that of the grey container minus the container's padding on the left and on the right side. 如果屏幕的宽度小于1024,则文本框应在标签下方,并且其宽度应与灰色容器的宽度减去在左侧和右侧容器的填充长度相同。

Please suggest me the way to do this. 请建议我这样做的方法。

I have also attached a screenshot: 我还附上了截图:

在此处输入图片说明

Here background with grey color is the container in website. 在这里灰色背景是网站中的容器。

.dnnForm .dnnFormItem {
    clear: both;
    width: 100%;
    display: block;
    position: relative;
    text-align: left;
}
@media screen and (min-width: 1025px)
    #rox-custom-box-06 .dnnForm {
        width: 100%;
    }
@media screen and (min-width: 1025px)
    #rox-custom-box-06 .dnnFormInput, .password-strength-container, .password-strength {
        display: inline-block;
        width: 35% !important;
    }

To accomplish this you are going to need to think a bit more granular in nature with your solution. 要实现此目的,您将需要在解决方案中考虑一些本质上的细节。

The Container &/or form will need to have specific CSS classes applied so that you can then make things work. 容器和/或表单将需要应用特定的CSS类,以便随后使工作正常。 You might also look at using Bootstrap or similar in your skin to assist as it looks like you are trying to make a responsive design, but without having any supporting framework. 您可能还会考虑在皮肤中使用Bootstrap或类似产品来提供帮助,因为您似乎正在尝试进行响应式设计,但没有任何支持框架。

Otherwise, a more detailed example with your HTML could assist. 否则,使用HTML的更详细的示例可能会有所帮助。

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

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