简体   繁体   English

将li布局显示为flex

[英]Display li layout as flex

Could anyone help to see why below code is not work as expected: 任何人都可以帮助查看为什么以下代码无法按预期工作:

I want the 2nd option content("Log when error occurs and limit ...") wrapped in the yellow background 我希望第二个选项内容(“发生错误时记录并限制...”)包裹在黄色背景中

 .flex{ display: flex; display: -webkit-flex; display: -moz-flex; display: -ms-flexbox; display: -ms-flex; position: relative; min-height: 0; min-width: 0; } .flex--1{ flex: 1 1 auto; } .flex--0{ webkit-flex-grow: 0; -webkit-flex-shrink: 0; -moz-flex: 0; flex: 0 0 auto; } input[type=radio].radio-button + label.radio-label { padding-left: 20px; height: 16px; display: inline-block; line-height: 16px; background-repeat: no-repeat; background-position: 0 0; font-size: 14px; vertical-align: middle; cursor: pointer; color: #666666; } li { list-style-type: none; display: list-item; } 
 <ul class="form__group"> <li>Send messages</li> <li> <input type="radio" name="log-options" class="radio-button" id="log-options-always" value="0"> <label for="log-options-always" class="radio-label ng-binding">always</label> </li> <li class="flex" style="background-color: yellow;"> <div class="flex--1"> <input type="radio" name="log-options" id="log-options-when-error" class="radio-button" value="1"> <label for="log-options-when-error" class="radio-label">Log when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache toLog when error occurs and limit log cache to</label> </div> <div class="flex--0 width--lg disabled" ng-class="{disabled: data.Log.AutoLog !== '1'}"> <input type="text"> <span>KB</span> </div> </li> </ul> 

Also see the fiddle . 另请参阅小提琴

It needs a min-height on the element to grow with its content so you change this 它需要min-height才能随其内容增长,因此您可以更改它

input[type=radio].radio-button + label.radio-label {
    padding-left: 20px;
    height: 16px;

to this 对此

input[type=radio].radio-button + label.radio-label {
    padding-left: 20px;
    min-height: 16px;

Side note: 边注:

Try use either CSS file (recommended) or inline style, as it is not recommended to have both. 尝试使用CSS文件(推荐)或内联样式,因为不建议同时使用两者。

So for example instead of this 所以例如代替

<li class="flex" style="background-color: yellow;">

you do this 你做这个

HTML 的HTML

<li class="flex yellowBg">

CSS 的CSS

.yellowBg {
    background-color: yellow;
}

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

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