Textarea Scrollbar not showing in firefox - html

I have a textarea which is dynamically create/inserted into the DOM. If the text area is below 75px height and the text inside of it exceeds that then you would expect a scroll bar however you don't see it.
Any other textarea that is larger than 75px will show the scroll bar properly.
Is there a way to fix this, or is that just a Firefox default behavior?
Here is my CSS
textarea {
position:absolute;
border:0;
overflow:auto;
resize:none;
}
UPDATED: The behavior is now not consistent, now it goes down to 60px below 60px no scrollbar

Works for me with height smaller than 75px. However, when the height of textarea is very small (about 35px) scrollbar won't fit and is therefore not displayed. Try adding following CSS for the textarea:
textarea {
resize: none; //disable resizing, so that the scrollbar is 100% high
overflow: auto;
}

As Firefox and Internet Explorer simply do not support any CSS styling of the scrollbar. Using a plugin really is your only option

Related

HTML reserve space for scrollbar

I have a div that may overflow as content is added or removed.
However the UI designer does not want a visible, but inactive scrollbar (as with overflow: scroll), and they don't want the content layout to change when one is added and remove (as with overflow: auto).
Is there a means to get this behavior, and considering the different scrollbars on different platforms and browsers.
https://jsfiddle.net/qy9a2r00/1/
No browser support this property yet (2021), but scrollbar-gutter is a suggested solution for this.
Update: 2022 - all modern browsers except Safari support the property.
The only way to do this is to make the width of the items in the container fixed. And you'll have to be conservative with the width of the scrollbar.
.container {
width: 200px;
height: 200px;
overflow: auto;
overflow-x: hidden;
border: 1px solid black;
}
.item {
width: 200px;
...
https://jsfiddle.net/fr1jnmn6/1/
overflow-y:overlay would be a partial solution to this as in, it solves the problem of not wanting the content layout to change when a scrollbar is added or removed. Extra padding or margin can be added so that scrollbar doesn't obfuscate the div behind
Here's the jsfiddle for the same https://jsfiddle.net/kitwradr/2qcsj6hw/
One cannot know how thick the scrollbar is, using only HTML & CSS and thus do not know the width of the (blue) placeholder.
You might solve such a task using scripting. Force a scrollbar in a hidden container and measure the inner and outer width. The difference being the scrollbar-width. Set this width (e.g. as CSS) to the placeholder element. And in the tricky part hide this element whenever a scrollbar is shown.
The usual solution to this problem is the one you do not want.
You can setup overflow: scroll to reserve space for scrollbar and add a class that makes scrollbar hidden
body {
overflow-y: scroll;
}
Hide the scrollbar by adding class to div (or to body) that will make your scrollbar transparent
.scroll-hidden::-webkit-scrollbar
{
background-color: transparent;
}
.scroll-hidden::-webkit-scrollbar-track
{
background-color: transparent;
}
To check if you have content overflow you can use this lines:
const { body } = document
const overflow = body.scrollHeight > body.clientHeight
If there are no overflow issue we will hide scrollbar and with reserve space
body.classList.add('scroll-hidden')
If content overflow we will show scrollbar
body.classList.remove('scroll-hidden')
Try the solution here https://jsfiddle.net/ycharniauski/y0pwftmq/
It's a bit hacky solution. Hope in future css will have some property to reserve space
You need to have a parent div with a fixed width (the final total width) and a child div with a width 16px smaller.
Then the scrollbar will have 16px free in the parent div.
The width should always be a number (can't be relative value). In the child div, you need to use a number as well. You can't do calc(100%-16px).
<div className="user-list">
<div className="user-list__content">
{content}
</div>
</div>
.user-list {
width: 500px; /* total width */
height: 1000x;
overflow-y: auto;
}
.user-list__content {
width: 484px; /* must be 16px smaller */
height: 100%;
}
This is an ancient question, but in case anyone comes looking.
Detect the scrollbar and show/hide your blue section based on the scrollbar being visible. If scrollbar is visible, HIDE your blue sections (apply a style). If not visible, show your blue padding section.
When the scrollbar becomes visible your padding hides, so the red and green sections will not change size or position.
This article below discusses detecting the scrollbar. You will want to set up a div somewhere to detect the current scrollbar width ahead of time in order to set your blue boxes to the same width.
How can I check if a scrollbar is visible?
Maybe append a div at the bottom will soft your problem ?
https://jsfiddle.net/moongod101/k7w574mw/1/

Text area scroll bar being displayed in IE 8

I an using a text-area of fixed size in a form to take input from user.Even though I have made the resize property of the text-area none the scroll bar is still getting displayed as seen in the picture.I don't want the scroll bar getting displayed in the text-area.
The code is working properly in Firefox and chrome though without any errors but in IE it's not..
HTML code...
<label for="qual" class="label">Description and Quantification of Impact to the extend possible:</label>
<textarea id="qual" rows="5" cols="50" style="resize:none" placeholder="Description and Qualification"></textarea><br><br>
CSS code...
.label
{
float: left;
width:120px;
padding:10px 30px;
<!--font-weight:bold;-->
}
textarea
{
<!--margin-bottom:90px;
margin-top:50px";-->
vertical-align:top;
}
.textarea
{
resize :none;
border: none;
width: 100%;
-webkit-box-sizing: border-box; <!-- <=iOS4, <= Android 2.3 */-->
-moz-box-sizing: border-box; <!-- FF1+ -->
box-sizing: border-box; <!-- Chrome, IE8, Opera, Safari 5.1-->
}
The output I'm getting in IE 8..
Even though i don't want the unselected scroll bar to appear it's still getting displayed..
I tried putting the code in jsfiddle but it won't open in IE 8 without errors that's why I posted the code and picture here..
just put style="overflow-y:hidden" to remove scroll
resize has nothing to do with scrollbars. You're looking for overflow.
If you want the scrollbar to appear only when the content is long enough to scroll, use overflow:auto
If you want to prevent all scrolling, use overflow:hidden
Just add overflow: auto; to textarea.
See http://jsfiddle.net/Volker_E/eQF22/2/embedded/result/
You could also add different properties specifically for horizontal overflow-x: hidden; or vertical overflow-y: scroll; (making scrollbars always persistent) scrollbars.

How to prevent horizontal scrolling on responsive webpage?

I'm using twitter bootstrap to make my app responsive. When I shrink the width of my browser window to the minimum size or view the page on a mobile device (iPhone, example), the user is able to scroll horizontally. The amount of horizontal scroll is small but I would like to remove it all together.
I believe it's due to the img container that I'm including, but I'm not here. The page's html is located here: http://pastebin.ca/2347946.
Any advice on how to prevent the horizontal scroll for the page while still maintaining the scrolling in the img container?
I had the same problem, and applied this to fix it:
body {
overflow-x: hidden !important;
}
.container {
max-width: 100% !important;
overflow-x: hidden !important;
}
To expand a bit, I only had the problem on mobile phones, so this is my final code:
#media screen and (max-width: 667px) {
body {
overflow-x: hidden !important;
}
.container {
max-width: 100% !important;
overflow-x: hidden !important;
}
}
I found the issues regarding this on Github, so I guess newer versions of Bootstrap have been patched.
i am pretty sure somewhere one of your child element is exceeding the width of its parent element. Check you code twice, if there any box-size of inner child elements is large because of one of the reasons like- when the box width including margin, padding, border go beyond the limit. And we possibly haven't added overflow: hidden; to its outer parent element. In this case they are considered reaching beyond their parent element and browsers show it with the scrollbar. So fix it via removing extra margins, paddings, borders or if you just don't want any headache, just try to add overflow:hidden; to the outer box.
The "overflow: hidden;" style is the remedy not the prevention.
If you want to prevent this you have to check your body elements which is larger than the body.
It happens when you take a div with some "padding" or "margin" outside ".container" class (twitter bootstrap).
So remove all padding and margin outside the container class.
It turns out I had zoomed in more than 100% that was causing the page to scroll. Cmd+0 helped bring the zoom to 100% which got rid of the scrolling.
Try to add (in the relevant #-rule) a max-width:
img {
max-width: NNNpx;
}
That'll prevent img from being too wide.

Textarea width in Chrome not being applied properly

Contact box in the footer the textarea and input boxes are in a div 310px wide.
http://www.bantros.net
They have been set to be 308px wide with 1px border. In IE9, Firefox and Opera everything is the same width but in Chrome (my default browser) the textarea overflows unless the width is set to 304px.
Using Inspect Element I can it reports it as being 314px wide but I'm not too sure why it is doing this. Any info or help will be appreciated, thanks
There is a browser-applied padding: 2px. Apply padding: 0.
.form1 textarea, .form1 input {
padding: 0;
}
This sort of issue can be solved using a CSS reset, btw.
One thing I can see, which I believe is the source of the problem: In textarea, chrome puts a 2px padding for left and right. In input chrome puts 0px padding on left and right.
If you override that it should be fine.

overlong image header, but how to only show horizontal scrollbar on body content?

I have a 4000px width image slap on the header of my site. for now, the way I hide the horizontal browser scrollbar is with this:
html
{
overflow-x: hidden;
}
Unfortunately that will make the horizontal scrollbar never appear. I would the browser scrollbar to appear when the main content of my site is hidden from view.
What is the technique/style for this?
Thanks
Put the image into a div with width: 100%, a defined height and overflow: hidden.
By the way, overflow-x is not supported by Internet Explorer 6, so it's not perfectly safe to use yet.