Make buttons stick to bottom of page *BUT* respect scrolling - css

I'm basically trying to add three wizard-like "step" buttons that (to me) naturally belong at the bottom of the page - "PREVIOUS" | "NEXT" | "FINISH". The three buttons are in a single div. The buttons need to always be at the bottom of the screen AND always at the end of the HTML content.
I've seen partial solutions to this that try to use position:fixed and that works fine if I have less a page worth of text to scroll through in the wizard - the buttons appear at the bottom of the screen using bottom:0px. But the problem is that sometimes I have a lot of text in the window and I need to scroll down quite some distance. I don't want to see the three wizard buttons until I get to the bottom.
I think basically, I sort of want to apply a conditional margin to my div, but I'm not sure how to do that.
Here's a fiddle that doesn't work to show what I'm trying:
[https://codepen.io/RiverTaig/pen/xzaVxX][1]

You can achieve this by setting height of #smallPage in vh using calc.
Remove the css of .wizard
var i = 0;
function toggle() {
var smallEl = document.getElementById("smallPage");
var bigEl = document.getElementById("bigPage");
if (i === 0) {
smallEl.style.display = "none";
bigEl.style.display = "";
i = 1;
} else {
smallEl.style.display = "0";
bigEl.style.display = "none";
i = 0;
}
}
.relative{
width:200px;
}
.wizard{
}
.content {
min-height: calc(100vh - 60px); /* Change as per your requirement */
}
<div class="relative">
<button onclick="toggle()">TOGGLE</button>
<div id="smallPage" class="content">
This has just a tiny amount of text and won't cause the page to scroll. Click the toggle button at the top to hide this div and load one with a lot more text. Hopefully the three buttons - "PREVIOUS", "NEXT", and "FINISH" - will still stay at the bottom!
</div>
<div id="bigPage" style="display:none">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur
</div>
<div class="wizard">
<button>Prev</button>
<button>Next</button>
<button>Finish</button>
</div>
</div>

Give your wizard container a fixed height. For our example, let that height is 100px. Now give it a fixed position like this:
.wizard-container {
height: 100px;
position: fixed;
bottom: 0;
left: 0; /* this property and value may depend on you design */
}
Now give your document container a margin-bottom of 100px (equivalent to the height of the .wizard-container)
As per my understanding this is the solution of your problem. Let me know if that doesn't help.
Respects

Related

avoiding overflow in grid with cell containing shape-outside

I am trying to build grid where some cells have elements combining shape-outside with some phrasing content. The shape is triangular (for simplicity), responsively filling half the cell.
My problem is that the phrasing content overflows the cell (and the grid) and my attempts at fitting the cell and grid break the shape-outside
.grid {
display: grid;
border: 1px solid red; /* to show overflow */
grid-template-columns: 1fr;
grid-template-rows: auto;
width: 600px; /* meant to be responsive but this width should show overflow occurring */
}
.cell {
grid-column-start: 1;
height: 100%;
border: 1px solid blue; /* to show overflow */
}
.shape-outside {
shape-outside: polygon(0 0, 100% 0, 0 100%);
clip-path: polygon(0 0, 100% 0, 0 100%);
background-color: lightblue;
width: 100%;
height: 100%;
float: left;
}
<div class="grid">
<div class="cell">
<div class="shape-outside">
</div>
<div>Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.
</div>
</div>
</div>
In the example I've set a fixed width to show the problem - in reality, I want 100%.
As far as I am aware too, the only way to do this exactly is programmatically, eg, using javascript.
However, if you are okay with an approximation, that mostly works, then the code below uses only CSS and HTML.
The underlying problem is that the floated element does not contribute to the layout flow, ie, it does not contribute to the size of its parent. This means that the other element, the text, is used by the browser to determine the size of the parent, but it does this BEFORE it gets wrapped around the float, so its apparent height is what a plain block of text would require. In your case, a right triangle, this means that the height is only half of what it should be.
The code below uses a hack to get around this by using a dummy set of the same text but with less than half the width, which means it will approximately result in a height double of what it would be otherwise. The dummy is then hidden from view. The dummy is then "covered" by the real text by placing the real text and float in a wrapper, content, which is positioned absolutely at 0 0, which is where the layout flow of the dummy has positioned the dummy.
The dummy sets the height, which sets the height of its parent, cell. The other child, content, can then set its height to 100% of the parent, which is the double height, and then the float and shape-outside can set their heights to 100% of that.
To contain the float and real text properly, their parent's, ie, content's, display needs to be set to flow-root to start a new flow control block, otherwise the float literally floats off into other places.
You may wish to play with the width in dummy to get the best value for your need, and also consider calc( nn% +- nnpx ) for example. Other fine tuning might include using box-size: border-box, other wise 100% does not mean 100%, etc.
.grid {
display: grid;
border: 1px solid red;
grid-template-columns: 1fr;
grid-template-rows: repeat(3, auto);
}
.cell {
grid-column-start: 1;
border: 1px solid blue;
position: relative;
}
.content {
display: flow-root;
position: absolute;
height: 100%;
}
.shape-outside {
shape-outside: polygon(0 0, 100% 0, 0 100%);
clip-path: polygon(0 0, 100% 0, 0 100%);
background-color: lightblue;
width: 100%;
height: 100%;
float: left;
}
.dummy {
visibility: hidden;
width: 40%;
}
<div class="grid">
<div class="cell">
<div class="content">
<div class="shape-outside"></div>
<div>Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
<div class="dummy">
Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
<div class="cell">
<div class="content">
<div class="shape-outside"></div>
<div>Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
<div class="dummy">Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
<div class="cell">
<div class="content">
<div class="shape-outside"></div>
<div>Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
<div class="dummy">Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut. Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.Sed exercitationem eum dolorem quam nam sit explicabo. Ut facere nihil architecto dolores ea consequatur tempore. Modi possimus omnis velit ut numquam excepturi vel. Culpa velit quisquam illum aut cupiditate aut quisquam ut.</div>
</div>
</div>
Text after the grid.
For this kind of adaptative job, you are going to need a little bit of javascript.
Demo:
https://vandrieu.github.io/adaptative-shape-outside/
CSS code:
Same than yours except I made width 100% instead of 600px
HTML code:
Just added a class="text" attribute on the text div
JavaScript code:
function resizeAllShapes() {
for (const cell of [...document.querySelectorAll('.cell')]) {
let currentCellHeight, textHeight
do {
currentCellHeight = Number(cell.style.height.replace('px', ''))
textHeight = cell.querySelector('.text').clientHeight
cell.style.height = `${textHeight}px`
} while (currentCellHeight !== textHeight)
}
}
new ResizeObserver(resizeAllShapes).observe(document.body)
Basically, for each cell, we are extending the cell's height until it matches the text's height.
It does not work at the first iteration because when we are extending the triangle the first time, it modifies the layout of the text, making the text overflow even further to the bottom. But it's not a heavy cpu loop, after only a few iterations, it just fits perfectly.
The resize observer allows the function to run at page load and each time the window is resized.
I'm sorry I can't suggest a pure CSS solution, but I'm almost certain there is none. The height of the shape depends on how much text has to fit, and how much text can fit depends on the height of the shape, so each variable depend on the other, so there is no declarative way of doing this, you just need to increase the shape size declaratively until it fits perfectly.
I hope that can help.

How to ensure scrollbar styling consistency between osx and windows?

I have a basic container with a scrollbar. The default scrollbar looks really nice on osx's browsers. But on Windows, I know the styling can be very old school. I don't own a windows computer. How to make sure the styling remains consistent between these os? Is there a simple way to force the style of the scrollbar so I can get this dark-thin-rounded rendering on windows too?
Here is a basic example:
body{
background:black;
}
.container{
background:#bbb;
height:150px;
overflow:scroll;
}
<div class="container">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</div>
This is impossible with native scrollbars of browsers. For example Firefox does not accept style for native scrollbar. Styling the native scrollbars with CSS will never be consistent. You have to use a virtual scrollbar library.
For example:
OverlayScrollbars (A javascript scrollbar plugin which hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.)
simplebar (Custom scrollbars vanilla javascript library with native scroll, done simple, lightweight, easy to use and cross-browser.)

Virtually infinite container (infinite width)

In the following situation, I don't want #blah to have linebreaks : I want its only limitation to be max-width: 20em;. It should not break lines here:
#container { position: absolute; width:100% }
#blah {
position: absolute;
font-size: 100px;
max-width: 20em;
}
<div id="container">
<div id="blah">Hahaha hahahah hah</div>
</div>
This is certainly caused by the fact the container is "only" 100% wide. Here
#container { position: absolute; width:10000% }
solves the problem.
But in my application I can have very very very large text, and very very very small text (see http://bigpicture.bi/demo).
Question:
How to make that #container is virtually infinite ? i.e. width: 100% is not enough, 1000% is not enough, and even 1000000% is not enough. Can I use width: infinity ?
Update
A different post and some comments have been deleted, which indicated that jQuery was okay to use, even though it wasn't tagged in the question.
My jQuery solution is below, but I've since come up with a much simpler solution: Add a width style to blah, which matches max-width. That way, container will automatically grow as needed:
#blah {
position: absolute;
font-size: 100px;
max-width: 20em;
width: 20em;
}
jQuery Solution (which may be useful for similar problems):
In the snippet below, I changed blah to a class instead of an ID.
You'll notice that max-width is ignored.
Click the Grow Container button. Each child of #container is cloned and given a static position, so we can determine its width. #container then grows as needed to match the width.
Now that #container has a width, its children can widen to match their max-width.
function growContainer() {
$('.blah').each(function() {
var clone= $(this).clone();
clone.css({position: 'static'});
$('body').append(clone);
var right= $(this).offset().left + clone.width();
$('#container').css({
width: Math.max($('#container').width(), right)
});
clone.remove();
});
} //growContainer
$('#BG').click(growContainer);
#container {
position: absolute;
}
#BG {
position: fixed;
}
.blah {
position: absolute;
max-width: 20em;
}
#blah1 {
font-size: 100px;
top: 50px;
background: red;
}
#blah2 {
left: 5000px;
font-size: 50px;
background: lightblue;
}
#blah3 {
top: 1000px;
font-size: 20px;
background: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="BG">Grow Container</button>
<div id="container">
<div class="blah" id="blah1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div>
<div class="blah" id="blah2">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? </div>
<div class="blah" id="blah3">
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. </div>
</div>

Vertical scrollbar although big div is hidden

I have 2 divs: a login form and a register form.
- The login form is fairly small
- The register form is longer than the browser height.
But even when the register div is hidden, I still have that vertical scroll bar...
Is there any way to ONLY disable the scrollbar when a div is active (overflow-y:hidden)
EDIT: My code: http://themavesite.com/testlogin/
please make sure the vertical bar is showing with the right DIV element,this is probably caused by render scrollbar in outer div
Please check out this fiddle.
Is it something like this you want? If something has class ".active" then disable body overflow?
HTML:
<a class="active">ACTIVE - DISABLE OVERFLOW</a>
<div>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?""Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?""Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</div>
CSS:
.active{
color:red;
}
JQuery:
var act = $(".active");
if (act){
$('html, body').css('overflowY', 'hidden');
}
Note: As you didn't share your own fiddle, I couldn't edit it, so I made this one.
Note2: If the scrollbar you want to hide is from some div instead of body just change the class from $(".active").

text-overflow:ellipsis; Can't get to work

Usually I accomplish this with PHP or JS if I needed to, but I'm trying to make this design responsive and for the life of me I cannot get the 3 dots to show up at the end of the cutoff string. Here's what I'm doing:
<article class="aBlogCont">
<h2><time class="aBlogDate" pubdate="pudate">12/18/13</time> : Welcome</h2>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
<hr />
</article>
And My CSS:
.aBlogCont{
width:29.33%;
padding-left:2%;
padding-right:2%;
height:350px;
overflow:hidden;
text-overflow:ellipsis;
display:inline;
float:left;
}
.aBlogCont > p{
overflow:hidden;
text-overflow:ellipsis;
}
From what I've read, this is correct. Here is my fiddle: http://jsfiddle.net/335F6/ Please let me know what I'm doing wrong.
Adding white-space: nowrap should fix it:
.aBlogCont > p{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
demo
Try adding white-space:nowrap; to .aBlogCont

Resources