gpt4 book ai didi

jquery - Bootstrap 警报自动扩展动态宽度父级

转载 作者:行者123 更新时间:2023-11-28 02:39:42 25 4
gpt4 key购买 nike

我已经尝试了一些我发现的关于堆栈溢出的解决方案,例如 display:inline-blockposition:absolute;顶部:0; left:0; 但是它们似乎都不适合我的问题。

我正在尝试使用 JQuery 来显示和隐藏基于用户在模糊事件中输入的错误消息,但是,当显示错误时,警报会自动扩展父 div,而我更喜欢宽度保持不变并在高度上向下扩展父级

register.php(修剪)

<div class="form-group" style="margin-bottom:0px">
<!-- Password -->
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-unlock" style="font-size:110%" aria-hidden="true"></i>
</div>
<label for="password" class="sr-only">Password:</label>
<input class="form-control" type="password" name="password" id="password" placeholder="Password" required>
</div>

<!-- Errors-->
<div class="alert alert-danger regError" id="nameInvalid" style="display:none;">
Invalid Name: Must contain both your first name and last
name, and consist of only alphabetic characters, dashes and
apostrophes.
</div>
<div class="alert alert-danger" id="numberInvalid" style="display:none">
Invalid Student Number: Student Number must seven digits.
</div>

<!-- Register Button -->
<div style="margin-top:5%">
<button type="submit" class="btn btn-success pull-right">Register</button>
</div>
</div>

样式.scss

html{
min-height: 100%;
position: relative;
}

body{
height: 100%;
}

//Login & Register
body.login{
background-color: $colour1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

#login-box{
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);
background-color: $colour4;
padding-bottom:2%;
padding-left:2%;
padding-right:2%;
border-radius: 5px;
position: relative;
max-width: 450px;
display:table;

}

.input-group-addon{
width: 18%;
}

.input-group{
width:100%;
}

.regError{
margin-top: 5%;
width: 100%;
display:inline-block;
}

enter image description here enter image description here

最佳答案

在您的错误框中添加宽度,以便将此 css 行添加到您的样式中。但未经测试导致您的整体风格在这里不起作用

#nameInvalid,#numberInvalid {
max-width: 400px;
/*add your extra style if needed */
}

关于jquery - Bootstrap 警报自动扩展动态宽度父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45205438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com