Element: select选择器可以制定宽度就好了。。。

Created on 8 Mar 2017  ·  5Comments  ·  Source: ElemeFE/element

ElementUI version

OS/Browers version

Vue version

Reproduction Link



Steps to reproduce

What is Expected?

What is actually happening?

All 5 comments

简单的 css 样式自己写就是了

http://jsfiddle.net/nzjacrb5/
http://jsfiddle.net/nzjacrb5/1/

是不是这些组件都可以加class来控制样式?

当然

厉害了我的哥

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