I'm having trouble with some div's position and layout.
The layout I want:
I want the title to always appear in full and on the right. The subtitle should appear on the left but with any overflow hidden so the title's length always takes precedent.
I have the following code:
<html>
<head>
<style type="text/css">
.title {height: 25px; text-align:left; width: 300px; border:1px solid red;}
.subtitle {height: 20px; overflow:hidden; float:left; border: 1px solid blue;}
</style>
</head>
<body>
<div class="title">
Title number 1
<div class="subtitle">This is subtitle that is longer with even more text</div>
</div>
</body>
</html>
At the minute if the subtitle is too long it just hovers underneath. Any ideas?
This is a good time to use
text-overflow: ellipsis
.http://jsfiddle.net/thirtydot/sxeu9/
HTML:
CSS:
Here is an attempt that seems to work: http://jsfiddle.net/3nCuJ/ (spelled out below)
Specifically, I made the title float right, rather than the subtitle floating left. This makes sure the entire title is visible, on top of the subtitle. Then in order to make the subtitle clip properly I added an inner div to contain the subtitle text.
If you want the subtitle to stop at a word boundary use this instead: http://jsfiddle.net/3nCuJ/1/
HTML:
CSS:
Hi it may not be the perfect solution but it is working... it can be a good start.
I positionned the main title over the sub title using the absolute positionneing and hide the subtitle text using a color bakground in the main title div.