Home > Web Front-end > H5 Tutorial > The input text exceeds the ellipses (code example)

The input text exceeds the ellipses (code example)

不言
Release: 2018-11-23 16:29:12
forward
3319 people have browsed it

The content this article brings to you is about the implementation of input text beyond the ellipsis (code example). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .

Input realizes the text ellipsis function

It is very simple for ordinary elements to realize that the text exceeds the width and automatically becomes an ellipsis. Add a width to the element, and then add these three Just use css:

    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
Copy after login

Have you ever thought about adding this effect to the input="text" element? As shown in the picture:

The input text exceeds the ellipses (code example)

input realizes the text beyond the ellipses function

<style>
    *{
        margin: 0;
        padding: 0;
    }
    .box{
        width: 200px;
        padding: 15px;
        border: 1px solid #f60;
        margin: 50px auto;
    }
    .form-control{
        height: 30px;
        line-height: 30px;
        padding: 5px 10px;
    }
    .text-ellipsis{
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }
    h2{
        width: 300px;
        margin: 10px auto;
    }
</style>

<h2>文字超出宽度自动变成省略号</h2>
<div>
    <input>
</div>
Copy after login

In fact, let input realize the text beyond Automatically changing the ellipses is also very simple, it’s the same three pieces of code. After testing, as of now (2018-11-23), only the latest Chrome and Firefox browsers support it, and the mobile version has not been tested!

The above is the detailed content of The input text exceeds the ellipses (code example). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template