Element: el-select 默认样式问题

Created on 6 Jan 2017  ·  4Comments  ·  Source: ElemeFE/element

el-select的宽度不随父容器自动扩充
http://jsfiddle.net/mgw28h1w/

这个是bug还是 调整成这样的?
之前会跟随父容器的宽度,现在最大宽度好像固定了。

.el-form-item{
  .el-select{
    width: 100%;
  }
}

我在自己项目中暂时加上了这样的样式解决了这个问题,不知道会不会有其他影响

Most helpful comment

1.1 的 break change

Input 和 Select 盒模型从 block 修改为 inline-block

https://github.com/ElemeFE/element/releases/tag/v1.1.0

我来替像我这样的小白回答详细一些:在el-select标签中添加 style="display: block"即可

All 4 comments

1.1 的 break change

Input 和 Select 盒模型从 block 修改为 inline-block

https://github.com/ElemeFE/element/releases/tag/v1.1.0

1.1 的 break change

Input 和 Select 盒模型从 block 修改为 inline-block

https://github.com/ElemeFE/element/releases/tag/v1.1.0

我来替像我这样的小白回答详细一些:在el-select标签中添加 style="display: block"即可

像楼上说的改就行了。比如我要修改选择框的宽度width就写成
<el-select placeholder="请选择" style="width:70%"></el-select>
就好了

Element-UIel-select 使用的其实是 input 标签 , 而 input 标签在浏览器中存在一个默认的宽度 , 大约是 100px (不同的浏览器表现不同) .

自定义的组件可以通过js来设置 inputwidthauto (hack方法)

function resizeInput() {
    $(this).attr('size', $(this).val().length);
}

$('input[type="text"]')
    // event handler
    .keyup(resizeInput)
    // resize on page load
    .each(resizeInput);

出处 : https://stackoverflow.com/questions/8100770/auto-scaling-inputtype-text-to-width-of-value


Element-UIel-select 的话不如直接设置它的 width ( 如果坚持使用el-select的话 , 也的确别无他法 ) 😞

<el-select placeholder="请选择" style="width:70%"></el-select>
或者
<el-select placeholder="请选择" style="width:120px"></el-select>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zhao-github picture Zhao-github  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

Kingwl picture Kingwl  ·  3Comments

fscardua picture fscardua  ·  3Comments

makunsusu picture makunsusu  ·  3Comments