所以我正在开发项目,我必须在HTML和CSS中模拟输入。在输入内部,我应该可以调用像my_cool_function(param0, param1, param2, param3)
这样的函数。因此,为了模拟输入,我创建了一个无序列表,在ul中我将函数添加为令牌。所以my_cool_function(param0,param1,param2,param3)本身就是一个完整的令牌。但param0
,param1
etcetera
也是令牌。所以这是我当前的html结构:
<ul class="list">
<li class="token">
<span>My_cool_Function</span>
<ul class="tokenparams">
<li class="token">
<span>Param0</span>
</li>
<li class="token">
<span>Param1</span></li>
<li class="token">
<span>Param2</span>
</li>
<li class="token">
<span>Param3</span>
</li>
</ul>
</li>
</ul>
这项工作提供了ul的宽度允许整个功能适合。因此,当宽度较低时,它会有一些断裂,我希望它能很好地包裹。这是css:
ul.list{
height: auto;
display: block;
width: 600px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
border: 1px solid #ccc;
cursor: text;
}
li.token{
display: inline-block;
white-space: nowrap;
margin: 0 10px 0 0;
padding: 0 1px 0 1px;
border: 1px solid transparent;
height: 18px;
vertical-align: top;
cursor: pointer;
}
li.token span {
float:left;
}
li.active {
border-color: #63B9FF;
}
ul.tokenparams {
list-style-type: none;
float: left;
padding-left: 0;
}
ul.tokenparams::before {
content: "(";
float: left;
margin-left: 2px;
}
ul.tokenparams::after {
content: ")";
margin-right: 2px;
}
ul.tokenparams .token:not(:last-child)::after{
content: ",";
}
因此宽度为600px时,它看起来像这样:
在355px时会发生这种情况:
这是一个显示错误的小提琴:http://jsfiddle.net/jvxzLt2s/
我想创建一个新行,并在新行中将其分解为param2
和param3
。
答案 0 :(得分:0)
这是你想要的吗?
http://jsfiddle.net/joe_young/jvxzLt2s/3/
我刚刚取出height
ul.list{
/* Removed 'height: auto;' here */
display: block;
width: 350px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
border: 1px solid #ccc;
cursor: text;
}
input.input{
border: 0;
margin: 0;
padding: 0;
font-size: 12px;
background-color: white;
-webkit-appearance: caret;
}
li.token{
display: inline-block;
white-space: nowrap;
margin: 0 10px 0 0;
padding: 0 1px 0 1px;
border: 1px solid transparent;
/* Removed 'height: 18px;' here */
vertical-align: top;
cursor: pointer;
}
li.token span {
float:left;
}
li.active {
border-color: #63B9FF;
}
ul.tokenparams {
list-style-type: none;
float: left;
padding-left: 0;
}
ul.tokenparams::before {
content: "(";
float: left;
margin-left: 2px;
}
ul.tokenparams::after {
content: ")";
margin-right: 2px;
}
ul.tokenparams .token:not(:last-child)::after{
content: ",";
}
答案 1 :(得分:0)
这将使ul.tokenparams li.tokens单独包装。
ul.list{
height: auto;
display: inline-block;
width: auto;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
border: 1px solid #ccc;
cursor: text;
}
input.input{
border: 0;
margin: 0;
padding: 0;
font-size: 12px;
background-color: white;
-webkit-appearance: caret;
}
li.token{
display: inline-block;
white-space: nowrap;
margin: 0 10px 0 0;
padding: 0 1px 0 1px;
border: 1px solid transparent;
height: 18px;
vertical-align: top;
cursor: pointer;
}
ul > li{float:left;}
li.token span {
float:left;
}
li.active {
border-color: #63B9FF;
}
ul.tokenparams {
border: 1px solid transparent;
display:inline;
list-style-type: none;
padding-left: 0;
width:auto;
}
ul.tokenparams::before {
content: "(";
float: left;
margin-left: 2px;
}
ul.tokenparams::after {
content: ")";
margin-right: 2px;
float:left;
}
ul.tokenparams .token:not(:last-child)::after{
content: ",";
}