CSS解决文本溢出加省略号

Home » CSS » 前端开发 » CSS解决文本溢出加省略号

文章归档

文件夹

偶然发现text-overflow:ellipsis这个属性,发现自己学习漏洞很大,先分享吧。

引用自:百度知道

使用text-overflow:ellipsis对溢出文本显示省略号有两个好处,一是不用通过程序限定字数;二是有利于SEO。需要使用对对溢出文本显示省略号的通常是文章标题列表,这样处理对搜索引擎更友好,因为标题实际上并未被截字,而是局限于宽度而未被显示而已。

通常的做法是这样的:
1.overflow:hidden;
2.text-overflow:ellipsis;
3.-o-text-overflow:ellipsis;
4.white-space:nowrap;
5.width:100%;

其中,overflow: hidden和white-space: nowrap都是必须的否则不会显示省略号;-o-text-overflow: ellipsis针对Opera;而宽度的设定主要是针对IE6;

该方法支持Internet Explorer, Safari, Chrome 和 Opera,但FF并不支持,不过可以通过Jquery来实现类似的效果。

下载这个Jquery插件:jQuery ellipsis plugin

调用方法:
1.$(document).ready(function() {
2.    $('.ellipsis').ellipsis();
3.}

 

22 Responses to “CSS解决文本溢出加省略号”
  • yeezy boost

    Thanks a lot for giving everyone an extraordinarily remarkable chance to discover important secrets from this web site. It is often very superb and also full of amusement for me and my office mates to visit your site at the least three times a week to study the fresh guides you have. And of course, I’m just always fascinated with the great methods served by you. Some 3 areas in this post are indeed the very best we’ve ever had.

    回复
  • nike air max 2017

    I and also my friends appeared to be examining the nice solutions found on your site while suddenly developed a terrible suspicion I had not thanked the web blog owner for those secrets. Most of the women were certainly joyful to read them and have now certainly been tapping into those things. Appreciate your being considerably accommodating and also for making a decision on varieties of ideal things most people are really desirous to know about. Our honest apologies for not saying thanks to you earlier.

    回复
  • yeezys

    I wish to get across my love for your kind-heartedness for folks who absolutely need assistance with this important topic. Your personal dedication to getting the solution around had become exceptionally beneficial and have surely permitted most people just like me to get to their ambitions. The valuable help can mean much a person like me and much more to my fellow workers. Best wishes; from everyone of us.

    回复
  • supreme clothing

    I am writing to let you know of the perfect encounter our child encountered studying your web page. She discovered plenty of pieces, with the inclusion of what it’s like to have an ideal teaching heart to let other folks with ease understand a variety of extremely tough issues. You truly did more than visitors’ expectations. I appreciate you for presenting those interesting, healthy, informative and even fun guidance on the topic to Ethel.

    回复
  • Adidas NMD x Kaws Black Colorful

    I happen to be commenting to make you know what a excellent encounter our daughter had reading through your web page. She came to understand too many details, which included how it is like to have a marvelous giving style to have others with ease completely grasp several hard to do things. You really exceeded visitors’ expected results. I appreciate you for displaying the invaluable, trustworthy, explanatory and cool tips on that topic to Sandra.

    回复
  • yeezy

    I want to convey my affection for your kind-heartedness for those people that should have assistance with that content. Your very own commitment to passing the message around appeared to be quite interesting and have really made individuals just like me to get to their desired goals. This warm and helpful useful information signifies this much to me and even more to my fellow workers. With thanks; from everyone of us.

    回复
  • balenciaga

    My husband and i were cheerful when Ervin could round up his analysis through your ideas he acquired when using the web site. It’s not at all simplistic to just happen to be giving freely things which many people may have been making money from. And we also consider we need the blog owner to be grateful to for this. The main illustrations you have made, the straightforward site navigation, the friendships you help instill – it’s many incredible, and it is assisting our son in addition to us reckon that the issue is cool, which is certainly wonderfully vital. Thanks for the whole thing!

    回复
  • adidas stan smith women

    I simply had to appreciate you once more. I am not sure the things that I would have tried in the absence of the type of opinions revealed by you on such area of interest. It had been the difficult concern for me, but viewing your expert tactic you handled it forced me to leap over gladness. I will be grateful for the assistance and even sincerely hope you recognize what a powerful job your are carrying out instructing the rest through the use of your blog. Most probably you haven’t met all of us.

    回复
  • converse outlet store

    My husband and i were now contented when Edward managed to conclude his preliminary research with the precious recommendations he got while using the weblog. It’s not at all simplistic just to continually be giving out information and facts that many other people might have been making money from. We really understand we have the website owner to thank for this. The illustrations you made, the simple site navigation, the relationships your site help to create – it’s got most powerful, and it’s really helping our son in addition to the family recognize that the idea is interesting, and that is wonderfully indispensable. Thank you for everything!

    回复
  • lacoste outlet

    I have to show my respect for your kind-heartedness giving support to those people that actually need help on this important subject matter. Your personal dedication to getting the message all-around became extremely informative and have without exception helped guys like me to arrive at their goals. Your warm and helpful useful information means a whole lot to me and especially to my office colleagues. Thanks a lot; from everyone of us.

    回复
  • yeezy boost

    I in addition to my guys have been reviewing the best tips found on the blog and then then got a horrible suspicion I never expressed respect to the blog owner for those secrets. My boys are actually passionate to learn them and have absolutely been using these things. Many thanks for actually being quite thoughtful and then for making a decision on this kind of excellent subject areas millions of individuals are really desperate to discover. Our sincere apologies for not expressing gratitude to you earlier.

    回复
  • nike flyknit

    I simply wanted to say thanks again. I’m not certain what I could possibly have implemented in the absence of the entire information revealed by you over my theme. It has been an absolute troublesome concern in my opinion, nevertheless witnessing a new professional avenue you managed it made me to leap over joy. I will be happier for your assistance and in addition sincerely hope you find out what a great job that you are carrying out instructing the mediocre ones by way of your site. More than likely you’ve never encountered all of us.

    回复
  • yeezy wave runner 700

    Thanks for your whole hard work on this web site. My mother really likes participating in research and it’s simple to grasp why. A number of us know all of the powerful form you convey efficient tricks via the website and in addition increase contribution from people about this subject matter while my child has always been becoming educated so much. Enjoy the remaining portion of the new year. You have been performing a wonderful job.

    回复
  • air jordans

    I wanted to draft you this very small note to finally thank you very much over again for your personal marvelous tips you have provided on this page. It was really tremendously generous of you to convey freely what a lot of people would have made available as an e-book to generate some profit for their own end, notably considering the fact that you could have done it in the event you wanted. The inspiring ideas also served to be a easy way to fully grasp that many people have the same desire much like my own to see significantly more on the topic of this issue. I’m sure there are millions of more pleasurable instances up front for individuals that find out your blog.

    回复
  • yeezy boost 350 v2

    I simply wanted to send a brief message so as to thank you for the remarkable points you are giving at this website. My incredibly long internet research has now been recognized with excellent tips to share with my friends and family. I ‘d assume that many of us website visitors are rather lucky to dwell in a superb place with very many wonderful people with valuable things. I feel very privileged to have discovered your webpage and look forward to tons of more amazing moments reading here. Thank you once again for everything.

    回复
  • bape hoodie

    My husband and i got really joyous that Chris could do his investigations using the precious recommendations he was given while using the web pages. It’s not at all simplistic to simply possibly be giving away tips and hints that many many people have been selling. We figure out we now have you to give thanks to for that. All of the explanations you made, the easy site navigation, the relationships you make it possible to engender – it is mostly excellent, and it is aiding our son in addition to us recognize that that issue is brilliant, and that’s truly serious. Many thanks for all!

    回复
  • yeezys

    I wanted to post a remark to be able to express gratitude to you for those lovely items you are giving on this website. My considerable internet investigation has at the end of the day been paid with pleasant content to go over with my classmates and friends. I would declare that we site visitors are definitely lucky to live in a wonderful community with many perfect professionals with very beneficial tips. I feel quite fortunate to have discovered your entire web page and look forward to plenty of more pleasurable moments reading here. Thank you once again for all the details.

    回复
  • adidas ultra boost uncaged

    I want to express my affection for your kindness giving support to those people that absolutely need help on your theme. Your personal dedication to getting the solution around appeared to be especially powerful and have frequently allowed ladies much like me to arrive at their endeavors. The insightful instruction entails a great deal to me and much more to my fellow workers. Thanks a lot; from everyone of us.

    回复
  • chrome hearts outlet

    Thanks a lot for giving everyone an extremely splendid opportunity to read critical reviews from this website. It really is so fantastic and as well , full of a lot of fun for me personally and my office friends to search your web site nearly 3 times weekly to read through the newest secrets you have. Not to mention, I’m certainly astounded concerning the staggering tactics you serve. Certain 4 facts on this page are surely the most suitable I have ever had.

    回复
  • hyperdunks

    A lot of thanks for your whole labor on this web site. My niece loves making time for investigation and it’s really obvious why. I know all regarding the dynamic form you render practical tips and tricks on this web blog and in addition recommend response from people on this theme plus our own simple princess has been discovering a lot. Have fun with the remaining portion of the new year. You have been doing a fabulous job.

    回复
  • asics shoes

    My spouse and i felt really fortunate that Emmanuel could conclude his researching through the entire ideas he made through your web site. It is now and again perplexing to just be offering information and facts which some people could have been making money from. And we all recognize we have the writer to be grateful to because of that. Most of the illustrations you made, the straightforward website menu, the relationships your site make it easier to instill – it’s most powerful, and it is making our son and us consider that the situation is enjoyable, and that is unbelievably mandatory. Thanks for the whole lot!

    回复
  • Cheap Yeezy Shoes

    Yeezyshttp://www.yeezy.com.co/
    Yeezyhttp://www.yeezys.us.com/
    Yeezyhttp://www.yeezysupply.us.com/
    Yeezy Sneakershttp://www.yeezy-shoes.us.com/
    Yeezy Boost 350http://www.yeezy-boost350.com/
    Yeezy Boost 350http://www.yeezyboost350.us.com/
    Yeezy Shoeshttp://www.yeezybluetint.com/
    Adidas Yeezy 500http://www.yeezy500utilityblack.com/
    Adidas Yeezy 500http://www.yeezy500utilityblack.us/
    Nike Air VaporMaxhttp://www.vapor-max.org.uk/
    Salomon UKhttp://www.salomon-shoes.org.uk/
    Salomon UKhttp://www.salomons.me.uk/
    Salomon Shoeshttp://www.salomonspeedcross4.org.uk/
    Off White Air Jordan 1http://www.offwhitejordan1.com/
    Vapor Maxhttp://www.nikevapormax.org.uk/
    Nike React Element 87http://www.nikereactelement87.us.com/
    React Element 87http://www.nikereactelement87.us/
    Nike Vapormax Plushttp://www.nikeplus.us/
    Nike Outlet Storehttp://www.nike–outlet.us/
    Nike Outlet Store Online Shoppinghttp://www.nikeoutletstoreonlineshopping.us/
    Nike Outlethttp://www.nikeoutletonlineshopping.us/
    NBA Jerseyshttp://www.nikenbajerseys.us/
    Air Max 97http://www.nikeairmax.us/
    Nike Air Max 2017http://www.max2017.us/
    Air Jordan Shoeshttp://www.jordan-com.com/
    Jordan 11 Concordhttp://www.jordan11-concord.com/
    Kanye West Yeezys Boost Shoeshttp://www.cs7boots1.com/
    Wholesale Cheap NBA Jerseyshttp://www.cheapnba-jerseys.us/
    Birkenstock UKhttp://www.birkenstocksandalsuk.me.uk/
    Basketball Jerseyhttp://www.basketball-jersey.us/
    Balenciagahttp://www.balenciaga.me.uk/
    Balenciagahttp://www.balenciagauk.org.uk/
    Balenciaga UKhttp://www.balenciagatriples.org.uk/
    Balenciaga UKhttp://www.birkenstocks.me.uk/
    Balenciaga UKhttp://www.balenciagatrainers.org.uk/
    Nike Air Max 270http://www.airmax270.org.uk/
    Yeezy Shoeshttp://www.adidasyeezyshoes.org.uk/
    Adidas Yeezy Shoeshttp://www.adidasyeezyshoes.org.uk/

    回复

发表评论

Your email address will not be published.