My container should bring up a scroll bar when there is an overflow. It doesn't show any scroll bar when it is not full. I have used "overflow: hidden" for this. It works fine in chrome and mozilla but it is not happening in IE8. I see that the overflow action is not being triggered.
html:
<div class="myBlock" style="overflow:hidden; outline:none;">...</div>
CSS:
.myBlock {
overflow-y: scroll;
height: 349px;
}
I need a scroll bar only on the y axis when my container overflows. Please let me know if i am missing out something. And also i'm getting the scroll bar in IE8 if i resize the window. This is a weird behavior and there is no resize functionality in my code.
Can you provide a little more information on the myBlock class?
Is your element absolutely positioned? If so, try changing it to relative and see if that fixes the issue - There is a weird IE8 quirk that could be fixed by applying position: relative.
Also, try using overflow: auto. This is the actual property you should set for showing the horizontol/veritcal scroll bar when necessary, otherwise hiding it.
EDIT:
Try setting your overflow-y style to overflow-y: scroll !important. This will ensure it takes precedence over your other overflow style. You can also set overflow-x and overflow-y separately to get the desired affect, why seems less hacky to me.
Related
I’m trying to achieve a similar effect on a Code Mirror component that would be achieved by doing overflow: hidden on a div.
In practice this means:
No visible scroll bars
When “scroll action” takes place on the editor, the website body moves itself (i.e., impossible to scroll editor relative to the website)
How could I do that?
P.S.
A simple “overflow: hidden” didn’t work because it looks like CodeMirror creates a separate div for vertical scroll bar and horizontal scrollbar. My guess is that javascript is used to handle actual scrolling behavior. Do I need javascript to revert this?
P.S.S.
I'm using react-codemirror2, but looking for a general answer and happy to figure out how to execute it within react.
Updated Answer
CSS, where .editor is the div wrapping the textarea:
.editor .CodeMirror-scroll {
overflow: hidden !important;
}
/* hide the scrollbars */
.editor .CodeMirror-vscrollbar, .editor .CodeMirror-hscrollbar {
display: none !important;
}
JS, where editor is your codemirror instance:
// does not allow focus within codemirror editor:
editor.setOption('readOnly', 'nocursor');
Then you can set your scrollTop() position by another editor if need be.
Issues:
cannot copy from the editor.
when selecting content, moving the mouse up and down will cause scroll. ~ going to look for a fix for this.
Set scrollbarStyle: null which Completely hides the scroll
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
scrollbarStyle: null
});
I'm also using react-codemirror2, it accepts className prop and preventing scroll can be done via css easily. You should add max-height with height: auto.
<CodeMirror
...
className={isScrollable ? 'disable-scroll' : ''}
/>
// sample css
.disable-scroll .CodeMirror {
max-height: 10rem;
height: auto;
}
I'm calling handleNotableTypeSelect method on the click of the check box, everything is working fine but the page jumps to the top.
this.$hideInactiveCheckbox.click(
this.handleNotableTypeSelect.createDelegate(this));
handleNotableTypeSelect: function(e) {
//e.preventDefault();
if (this.$hideInactiveCheckbox.attr('checked')) {
this.isActive = "^active$";
this.$connTable.fnFilter(this.isActive, 1,true);
}
else {
this.$connTable.fnFilter('', 1);
}
//return false;
}
My case was that the checkbox was hidden (due to CSS design). the original input checkbox had position set to 'absolute' so when the user clicked the checkbox the page "jumped" to the real checkbox position.
EDIT:
In some cases there are styled "fake" checkboxes. the real checkbox element is hidden in some bad practice way.
My case was that the real checkbox element had absolute positioning and hidden and that cause the page jump to top of the window.
Possible solution:
Check if the checkbox element has the following CSS rule
position: absolute;
if yes, removing this rule can fix this issue.
This may related to the following issue:
input checkbox in div jumps to top of page on firefox
I've actually been seeing errors about this in all kinds of frameworks, and for the most part, people post framework specific answers. If you're hiding the check box, try using display: none on it, it seemed to work for the post above. I'm still trying to hunt down a fix (since I'm not hiding my checkboxes, I'm trying figure out why checkboxes in a modal cause the screen to jump to the top of the modal on click).
Several frameworks and css tricks hide the checkbox using position: absolute.
That is correct because we need to hide the checkbox only from screen, while Screen Readers must have access to it in order to announce it correctly. But display:none hides it from them too and users with accessibility issues can't click it.
The most suitable solution is to add position:relative to checkbox container and adjust checkbox position using top: if needed.
If your check box has position: absolute, in most cases just wrapping it (input and label elements) with a div should be enough.
If the checkbox has been positioned absolute to hide it and the interaction occurs on the label (which is commonplace when styling checkboxes beyond the default UI), the page will scroll to wherever the checkbox input is positioned despite the click event occurring on the label. so if you've added top:-9999px; for example, the page will jump right up to where it's now positioned.
What you want instead, is to remove it from the rendered layout without moving it away from the label. to do this, add a container div to the label and input, and add position:relative; to it. Then add the following code to the input itself:
position:absolute;
top:0; left:0;
visibility: hidden;
opacity: 0;
I am using TextArea tags in my web project, that shall never show scrollbars.
This can easily be accomplished using
TEXTAREA { overflow: hidden }
All browsers that I need (IE, FF, Chrome) hide the scrollbars, as intended.
However Internet Explorer and Chrome will scroll to the current cursor position anyway, while Firefox does not scroll anymore at all. You can move the cursor into the invisible area and type, but you will not see, what you are doing.
Can this be solved?
Regards,
Steffen
EDIT: Because I have not found the source of the problem and I would really like to solve this, I leave this question open. However I found a really bad workaround: We now use overflow: scroll on that TEXTAREA, put it into a DIV, measure the width and height of the horizonal and vertical scrollbars, increase the size of the TEXTAREA by that values and set overflow:hidden to the DIV effectivly clipping away the scrollbars. They get invisible to the user but Firefox still scrolls. Not nice but working.
As far as I can tell, Firefox is behaving as I'd expect given the semantics behind overflow:hidden.
That said, and having read your comments above, you can quite easily mimick the behaviour you want with a small bit of jQuery.
Here's the code I've written:
$('textarea').bind("focus keyup", function(){
var $current = $(this);
$current.scrollTop(
$current[0].scrollHeight - $current.height()
);
});
This will basically scroll the textarea to the bottom when you focus on it and as you type. It may need tweaking to account for edits being done further up in the content.
Here's a Working Demo
I have a page with a couple DIVs with contents loaded via ajax. After the contents loaded, the page doesn't dislay the scrollbar to show all the DIV contents (I can't scroll down to see the rest of the content.) I tried with Firefox and IE. All have the same problem. Is there away I can fix this?
Did you try to set style on the div or class?
overflow: auto;
Without seeing the HTML and CSS, all I can offer is a few suggestions:
Maybe you have unclosed tags.
The div style might prevent correct display. What's the overflow set to?
If you're loading into a div that's in a document in an iframe, you get this kind of stuff a lot.
Can you scroll around the div with TAB or by mouse-selecting its contents? Maybe the content isn't even being loaded fully.
In CSS I had the position of the div as fixed
div.query_res{
position:fixed;
top:40px;
left:445px;
}
changed it to
div.query_res{
position:relative;
top:40px;
left:445px;
}
And all was good.
This is quite old, but just in case some else gets here, as me, you have to redraw the page, as the calculations to add a scroll has been already made. So you have to tell the browser to redraw as the content size has changed. You can test if this is the case by changing the size of the window, if doing so gets back the scroll bar, then redraw after generating the DIV or whatever you are generating.
I'm having this issue in IE7 with my drop down. Whenever I hover over my dropdown it goes up as soon as i hover over an element on top of the content. http://www.legrandconfectionary.com/gift-boxes/
I thought a position: relative on the header would solve the problem but on certain pages like the truffle flavors I have a tooltip effect that goes under the nav if done so. I'd really appreciate some help on this. Thanks!
There are several ways that you can fix this. Here's two:
Set the a tag to display: block, and then make your hover events based on the a instead of the li.
or
Specify a height other than auto or 100% for the li's