How can I cut long text according to available div area size?
Tags: javascript,css,html5
Problem :
I have a text and preview div area. Whenever I have put long text on the div area, it is overflowed out of div area. I have tried text-wrap:normal
, but it does not cut the context and showed only what text fit to the available area.
How can I cut long text according to available div area size? Afterwards, I will put css read more button to end of preview text area.
Solution :
Use text-overflow: ellipsis;
, that when combined with overflow: hidden
and one-line technique white-space: nowrap
adds a ...
at the end of the text, containing it within the parent's width:
div {
overflow: hidden;
width: 100px;
white-space: nowrap;
text-overflow: ellipsis;
float: left;
}
<div>
my very long text is here my very long text is here
</div>
<a href="">[Continue to read]</a>
CSS Howto..
HTML: <div class="element"></div> CSS: .element { border-bottom: 2px solid #00f; position: relative; } .element::before { background-color: #f00; content: ""; height: 2px; position: absolute; width: 25%; } Demo: JSFiddle...
Add .current-menu-ancestor to the current menu item selectors, as follows: div.custom-sidebar .menu li.current_page_item > ul, div.custom-sidebar .menu li.current-menu-ancestor > ul, .menu li.current-menu-item > ul, .menu li.current-menu-ancestor > ul {display:block;} ...
You can use pseudo-class to do this : .imgContainer{ position:relative; display:inline-block; } .imgContainer:before{ content:''; border:1px solid green; position:absolute; width:100%; height:100%; top:10%; left:10%; z-index:-1; } <div class="imgContainer"> <img...
The box-shadow property supports a keyword called "inset" for box-shadow inside a box. E.g. box-shadow: inset 0 -10px 5px 5px hsl(0, 0%, 90%); (btw, no need for the prefixes, see...
Flexbox can do that: .chatbox { margin: 1em auto; width: 150px; height: 500px; border: 1px solid grey; display: flex; flex-direction: column-reverse; justify-content: flex-start; text-align: center; } .message { background: lightgreen;...
Its a very simple one, you can pass the class you need this way, <?php echo CHtml::errorSummary($model, null, null, array('class'=>'className')); ?> or <?php echo $form->errorSummary($model, null, null, array('class'=>'className')); ?> so...
you can write the css like this: box-shadow:rgba(0,0,0,0.4) 1px 1px, rgba(0,0,0,0.4) 2px 2px, rgba(0,0,0,0.4) 3px 3px; demo For more details,click#box-shadow...
There were some thing wrong with your code: You've 2 the same ID's (the A and the DIV), updated with data-target. You were searching for "#selected" instead of ".selected", updated...
use rgba background. background: rgba(0, 0, 0, 0.5); values are in order red intensity, green intensity, blue intensity the decimal value is the opacity, and it runs from 0 to...
You need to look for any rowspan= attribute in the selected tds and if present, select the subsequent row(s) as well. This example should support any rowspan value (it appends...
Looking at your screenshot, it appears you want the leaf background tiled everywhere accept for underneath the white container, which should just be grey. You could tile the main container...
add to UL.tabs A border-bottom-color:rgb(221, 221, 221); border-bottom-style:solid; border-bottom-width:2px; ...
You generally do not want to include CSS in application.css and instead use this just for directives. If you do include CSS there, Rails will include it after all directives,...
You can enable View Shadow DOM in DevTools console and view styles associated with Shadow DOM elements. Hit F12 > F1 to open DevTools >> Settings >> Preferences You will...
Try this: http://jsfiddle.net/0k698ga2/2/ I used this piece of CSS. Hope it helps. #main{ width:100%; display:table; //table-layout:fixed; border:1px solid red; position:relative; } ul{ list-style:none; padding:0;margin:0; // overflow-y:scroll; height:100%; } #left {...
Using the CSS first-of-type selector. The below CSS will select only the first instance of element type p within the element with class container. .container > p:first-of-type{ /* css */...
The only way I know how to do this is with flexbox: .container { width: 300px; height: 100px; border: 1px solid red; display: flex; flex-direction: column; } .head { border:...
To target not IE with conditional comments. <!--[if !IE]> --> According to the conditional comment this is not IE 5-9 <!-- <![endif]--> And you can do even more advanced stuff:...
Float the sections left: .featureds { position:relative; width:150px; height:100px; background-color: #eef; border-color: #000; border-width: 2px; border:1px solid #333; float:left; } jsFiddle example...
Try using Descendant Selectors: a img { border-bottom: none; } If it doesn't seem to be working, first make sure that the selector is correct (i.e. is referencing the correct...
The RTE2_GenerateLaunchArguments method in HtmlEditor.js copys all of the stylesheets and styles on the page: var styleRules=new Array(); var styleRulesUrl=new Array(); for (var i=0; i<document.styleSheets.length; i++) { var styleSheet_href=document.styleSheets[i].href; if...
You'll need a bit more CSS. Remove the inline style from the table and add the CSS below to your code. table { border-collapse: collapse; /* Collapses the margins between...
I have just worked it out. Sorry to bother you guys. .img { position: relative; } .img .btn-panel { position: absolute; margin-top:-50px; //did the job when combined with top 50%...
The typical way to do this is to position the tab element over the sub element, so as to cover up that section of the border. However, the use of...
There is no way to force the browser to maximum height. You can write css like .max_width{ width: 100%; } this will make the container 100%. But the height will...
Wow, going back to basics after using a framework is hard work. var element = document.getElementById('BottomCell').previousSibling; var parent = element.parentNode; parent.removeChild(element); ...
I ended up solving it like this (with javascript/jQuery): -Create a div -Insert the image -pick up the dimension from the image -set those dimensions to the DIV -set image...
Browser compatibility is a very lengthy topic and it covers more than one area to perform correctly. If IE 7 or IE browsers are your only problem, then CSS Conditional...
That's the code: You need to check the length of your array. ng-class="{'active': vm.settings.customfields_student.length==0 }" Here is a working fiddle....
To the degree that unencoded DATA URIs work at all (some browsers insist on Base-64 encoding), you'll still want to quote the contents of url(), albeit with escaped quotes: $('span').css(...