Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing text left in a Div

I have a breadcrumb pages showing in a div.( 25px high by 700px wide) The trouble is I have so many pages that the page titles in the breadcrumb are spilling out of the div. Is there a way for the last few breadcrumbs pages to force the first breadcrumb pages left out of sight and diplay the last ones fitted in the Div

Hope this makes sense

Regards

R

like image 419
Rifki Avatar asked Mar 02 '26 05:03

Rifki


2 Answers

Yes, you can use overflow, float and white-space.

HTML:

<div class="breadcrumb-container">
    <div class="breadcrumb">
    Start aaaa aaaa End
    </div>
</div>
<div class="breadcrumb-container">
    <div class="breadcrumb">
    Start aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa End
    </div>
</div>

CSS:

.breadcrumb-container {
    float:left; max-width:100%; margin:5px; overflow-x:hidden; background:orange;
}
.breadcrumb {
    float:right; margin:5px; white-space:nowrap; background:cyan;
}

This will force the links to stay on a single line and hide any overflowing text off the left hand side, so the last categories are visible. The float:left stops the breadcrumbs from starting from the right margin.

like image 187
BoffinBrain Avatar answered Mar 04 '26 22:03

BoffinBrain


This seems to work in Chrome; heck knows what earlier versions of IE will make of it though:

HTML

<div class="breadcrumb-container">
<ul class="breadcrumb">
    <li>1 breadcrumb item</li>
    <li>2 breadcrumb item</li>
    ...
    <li>10 breadcrumb item</li>
</ul>
</div>

CSS

.breadcrumb-container {
    float: left;
    max-width: 100%;
}

.breadcrumb-container .breadcrumb {
    float: right;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.breadcrumb-container .breadcrumb li {
    display: inline;
}

http://jsfiddle.net/Bu4J5/2/

like image 42
Paul D. Waite Avatar answered Mar 04 '26 21:03

Paul D. Waite



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!