Scrollbar appears next to sliding-menu - html

I have an ons-list(basically a list) in my view that I want to have a scrollbar, so I added some css to my index.html, namely the following one:
<style>
::-webkit-scrollbar {
display: block !important;
width: 5px;
height: 0px;
}
::-webkit-scrollbar-track {
background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
border-radius: 2px;
background: rgba(0,0,0,0.3);
-webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.5);
}
</style>
This helps with the scollbar problem for the ons-list, but it also shows an "external" scrollbar to the whole page that is always there.
Is there any way to remove that?
Here's a screenshot to show you what i'm talking about:
You can see, that the scrollbar is tied to the main page, because in the following screenshot, I'm sliding the ons-sliding-menu to the left, and the scrollbar is tied to the main page.
Index.html looks like this :
<ons-sliding-menu main-page="navigator.html" menu-page="menu.html" side="right" max-slide-distance="250px" var="menu">
</ons-sliding-menu>
<ons-template id="menu.html">
<ons-page ng-controller="menuController" ng-init="initMenu()">
<ons-list>
<ons-list-item modifier="tappable" onclick="menu.setMainPage('navigator.html', {closeMenu: true})">
<ons-icon icon="ion-home" style="padding-bottom:2px;"></ons-icon> Home
</ons-list-item>
<ons-list-item modifier="tappable" onclick="menu.setMainPage('Page1.html', {closeMenu: true})">
<ons-icon icon="ion-clipboard" style="padding-bottom:2px;"></ons-icon> Page1
</ons-list-item>
<ons-list-item modifier="tappable" onclick="menu.setMainPage('Page2.html', {closeMenu: true})">
<ons-icon icon="ion-loop" style="padding-bottom:2px;"></ons-icon> Page2
</ons-list-item>
</ons-list>
</ons-page>
</ons-template>
<ons-template id="navigator.html">
<ons-navigator title="Navigator" var="myNavigator" page="main.html">
</ons-navigator>
</ons-template>
<ons-template id="main.html">
<ons-page id="main" >
<ons-tabbar>
<ons-tab active="true" page="page_1.html">
<div class="tab">
<ons-icon icon="ion-calendar" class="tab-icon"></ons-icon>
<div class="tab-label">Page_1</div>
</div>
</ons-tab>
<ons-tab page="settings.html">
<div class="tab">
<ons-icon icon="ion-gear-a" class="tab-icon"></ons-icon>
<div class="tab-label">Settings</div>
</div>
</ons-tab>
</ons-tabbar>
</ons-page>
</ons-template>

It seems the body content is taking more space and resulting in the outer scroll bar.
You can try this to avoid the outer scroll bar -
body {
overflow-y: hidden;
}

I'm guessing you're using Onsen 1, since these issues shouldn't be present in Onsen 2. Apart from upgrading you can do the thing which #Nitesh suggested - just write overflow: hidden on the elements which you don't want to have a scrollbar.
The trick is that these scrollbars probably don't come from the body, but more likely from ons-page. Those pages insert a .page__content and put your content there. So you could try something like
.page__content {
overflow: auto;
}
Or if you're sure that the one which you don't want comes from the main page you could do something like:
#main > .page__content {
overflow: hidden;
}
If that doesn't help you should be able to debug the problem in a browser. right click -> inspect element and you can find the specific element which has the scrollbar.
An alternative would be not to change the styles of the scrollbars by default, but just to use the ons-scrollbar tag wherever you want a scrollbar.

Related

Iframe overflow takes a new line instead of a scroll bar

I created a web site that shows the directory list in the server. In backend all the directories are getting indexed and shown in an another webpage called dirpage. So I used an iframe in mainpage to show the content of dirpage. The mainpage and dirpage are working great. But when the dirpage is shown in the iframe, the content overflows. The iframe width is limited to the <div> width. The problem is the iframe overflow is taking a new line to show the content.
Here is the main page.
<head>
<style>
#divmain{
display: flex;
flex-direction: row;
}
#div1{
background: rgb(244, 236, 225);
width: 30%;
height: 600px;
float: left;
}
#div2{
background: black;
width: 70%;
height: 600px;
float: right;
}
#button1{
height:44px;
width:50px;
float:left;
}
#button2{
height:44px;
width:50px;
float:left;
}
#input1{
display:none;
float:right;
width:295px;
height:44px;
}
#iframe1{
height:500px;
width:390px;
background: transparent;
overflow: scroll;
}
</style>
</head>
<body onmousedown="buttonclick1(event)">
<h1>online storage</h1>
<div id="divmain">
<script>
function buttonclick1(e){
if (e.target.id !== "input1")
document.getElementById("input1").style.display="none"
}
function buttonclick2(e){
if (e.target.id == "button1")
document.getElementById("input1").name="folder"
if (e.target.id == "button2")
document.getElementById("input1").name="file"
}
</script>
<div id="div1">
<hr style="margin-top:0;">
<button id="button1" onclick="document.getElementById('input1').style.display='block'" onmousedown=buttonclick2(event)><a>Folder</a></button>
<button id="button2" onclick="document.getElementById('input1').style.display='block'" onmousedown=buttonclick2(event)><a>File</a></button>
<form id="form1" action="session" >
<input id="input1" type="text" name="">
</form><br><br>
<hr style="margin-top:10px;"><br>
<iframe id="iframe1" src="dirpage.html">
</iframe>
</div>
<div id="div2">
</div>
</div>
</body>
Here is an image of dirpage and mainpage. I can't add the code of dirpage. because the content are very sensitive. It doesn't contain anything other than <p> paragraphs and buttons.
Now what I need to do is show the overflown content with a scroll bar.
Not with a newline.
I tried overflow: scroll. But It's not working. Any help would be greatly appreciated.
From what I understood, your problem is that the iframe is not expanding by width and thus instead of staying on one line when exceeding the width it's creating a new line?
EDIT:
Ok after testing your page here's what I found. Initially after starting with a plaintext, it had css from the browsers that gave the text a <pre> tag with a white-space: pre-wrap; style, your problem can be fixed by removing the pre-wrap style from the css, the problem is you can only edit it from the Inspect Element menu.
On the other hand, after trying with an html file instead of a txt file, the "line break" only happens after adding a spacebar to the text, which is expected.
I'll see what I can do from here but I thought I would update to as opposed to keeping you waiting.
I recently had the same issue, and also tried overflow: hidden;, but it didn't work because there isn't a limit of how big the div can get.
So you need to limit the size of the div like: max-width: "width" and max-height: "height". Or just define the fixed width and height if you don't want it to scale.
Related answer: Overflow Scroll css is not working in the div
Edit:
If overflow: hidden; didn't work try applying it for overflow-x: hidden; & overflow-y: hidden;

How do i use #media print queries with a dynamic web page? All i'm getting is a blank page currently

I have a dynamic web page that is generated when a user clicks to view more details on a car. I basically want a button that says 'Print Details' so the customer can print the vehicle details, but I don't want it to print the header and footer just the bits in the middle. So I currently have (without pasting allll my code) a div with my header and a div with my footer. Then I have a section tag using the class's 'section white'. When the user clicks print, I want to print JUST the section tag and everything inside it. However currently when I've tried this I just get a blank page..
This is the code I'm currently using to try and do it.
<style type="text/css">
#media print {
body * {
visibility: hidden !important;
}
.section .white {
visibility: visible !important;
height: 100%;
width: 100%;
position: fixed;
background-color: blue;
top: 0;
left: 0;
margin: 0;
padding: 15px;
font-size: 14px;
line-height: 18px;
z-index: 9999999;
}
}
</style>
I won't paste my HTML page, only because it's a lot of code but the structure looks like this.
<html>
<body>
<div class="header">
</div>
<section class="section white">
</section>
<div class="footer">
</div>
</body>
</html>
body * {
visibility: hidden !important;
}
This hides everything inside the body.
.section .white {
visibility: visible !important;
}
This unhides anything with class="white" that is a descendant of anything with class="section".
You aren't selecting the section
<section class="section white">
The only element with class="white" is the same element as has class="section". It is not a descendant of it.
Remove the descendant combinator:
.section.white {}
You have no content to print
<section class="section white">
</section>
There's nothing to see. You have to have some content for it to show up!
If you did have content, then any elements would still be hidden
body * would match them and hide them.
Just hide the elements you need to hide, and nothing else. Use selectors that actually match them.
Write semantic markup while you are at it. Don't use classes which match element types, either use better class names or the actual element types.
Avoid !important, it is almost always more trouble than it is worth.
body > :not(section):not(.white) {
visibility: hidden;
}
<header>
This is the header
</header>
<section class="white">
<p>This is a section</p>
<p>...</p>
</section>
<footer>
This is the footer
</footer>

Unable to hide scrollbar inside an iframe?

I have embedded an iframe n my page with content from another site.Here is a link if you want to visit it http://8mags.com/bored/wtf/wtf01.html
The problem is that I am unable to remove the scrollbars and a few other things.
My CSS code is here
html {
overflow-x: auto !important;
overflow-y: auto !important;
}
body {
overflow-y: auto !important;
background: white !important;
}
The problem is that scrollbar is still there.Also the background does not change to white inside iFrame.I also tried to hide a few details with this code
.quote-subtitle {
display: none !important;
}
but it does not work either.
EDIT
The code that produces the iFrame is this one
<span class="quora-content-embed" data-name="What-are-some-of-the-most-awesome-psychological-facts/answer/Arjun-Subramaniam/quote/2114886">Read <a data-width="541" data-height="893" class="quora-content-link" href="http://www.quora.com/What-are-some-of-the-most-awesome-psychological-facts/answer/Arjun-Subramaniam/quote/2114886" data-embed="nqjyswb" data-type="quote" data-id="2114886" data-key="78561af9adeb1d847ceae88107798254">Quote of Arjun Subramaniam's answer to What are some of the most awesome psychological facts?</a> on Quora<script type="text/javascript" src="http://www.quora.com/widgets/content"></script></span>
<body class=" logged_out" style="overflow: hidden;">
i use this on link and worked,and hidden the scrollbars.
or use this to access content of iframe
$('#iframe').contents().find('body').css('overflow','hidden');

Hide scrollbar in firefox

I want to hide a scroll bar in page but I can scroll like it has a scroll bar.
so I cant use overflow:hidden because I want that I can scroll like normal
but cannot see a scroll bar.
so I use this css code (class not-scroll-body is a class of body tag)
.not-scroll-body::-webkit-scrollbar {
display: none;
}
It works in Chrome , but when I use -moz- instead of -webkit- like this
.not-scroll-body::-moz-scrollbar {
display: none;
}
It doesn't work in Firefox.
What can I do to to make it work?
Thank you for every answer and sorry for my poor english language :)
In firefox 64, if you want to hide scroll when you have overflow:auto you can now do scrollbar-width: none;! Woop woop! Here are the relevant docs (browser support is show at bottom of page).
Below is a simple css only solution that will hide your vertical and horizontal scrollbar in firefox (tested in v64 & firefox dev edition v65.0b8). Hint: try vertical and horizontal scrolling on the blue div.
.not-scroll-body {
overflow: auto;
height: 200px;
width: 90%;
background: linear-gradient(to bottom, cyan, blue);
white-space: no-wrap;
/* the line that rules them all */
scrollbar-width: none;
/* */
}
span {
width: 200%;
height: 400%;
background: linear-gradient(to left, green, yellow);
display: inline-block;
margin: 5rem;
}
<div class="not-scroll-body"><span></span></div>
According to this answer and everything I've been able to find on the web, there's no Firefox equivalent of the -webkit-scrollbar selector. Apparently there used to be a property, -moz-scrollbars-none, that you could use for this, but it's since been removed and people recommend using overflow:hidden or a hackish margin-right: -14px solution.
Sorry I can't be more helpful -- it seems like there's no Firefox way to do this elegantly.
I was able to hide the scrollbar but still be able to scroll with mousewheel with this solution:
html {overflow: -moz-scrollbars-none;}
Download the plugin https://github.com/brandonaaron/jquery-mousewheel and include this function:
jQuery('html,body').bind('mousewheel', function(event) {
event.preventDefault();
var scrollTop = this.scrollTop;
this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
//console.log(event.deltaY, event.deltaFactor, event.originalEvent.deltaMode, event.originalEvent.wheelDelta);
});
cf: https://stackoverflow.com/a/41021131/4881677
This is how I do it, only CSS and works well with frameworks like bootstrap. It only needs 2 extra div:
You can select the text to make it scroll or scroll it with fingers if you have a touchscreen.
.overflow-x-scroll-no-scrollbar {overflow:hidden;}
.overflow-x-scroll-no-scrollbar div {
overflow-x:hidden;
margin-bottom:-17px;
overflow-y:hidden;
width:100%;
}
.overflow-x-scroll-no-scrollbar div * {
overflow-x:auto;
width:100%;
padding-bottom:17px;
white-space: nowrap;
cursor:pointer
}
/* the following classes are only here to make the example looks nicer */
.row {width:100%}
.col-xs-4 {width:33%;float:left}
.col-xs-3 {width:25%;float:left}
.bg-gray{background-color:#DDDDDD}
.bg-orange{background-color:#FF9966}
.bg-blue{background-color:#6699FF}
.bg-orange-light{background-color:#FFAA88}
.bg-blue-light{background-color:#88AAFF}
<html><body>
<div class="row">
<div class="col-xs-4 bg-orange">Column 1</div>
<div class="col-xs-3 bg-gray">Column 2</div>
<div class="col-xs-4 bg-blue">Column 3</div>
</div>
<div class="row">
<div class="col-xs-4 bg-orange-light">Content 1</div>
<div class="col-xs-3 overflow-x-scroll-no-scrollbar">
<div>
<div>This content too long for the container, so it needs to be hidden but scrollable without scrollbars</div>
</div>
</div>
<div class="col-xs-4 bg-blue-light">Content 3</div>
</div>
</body></html>
Short version for lazy people:
.overflow-x-scroll-no-scrollbar {overflow:hidden;}
.overflow-x-scroll-no-scrollbar div {
overflow-x:hidden;
margin-bottom:-17px;
overflow-y:hidden;
width:100%;
}
.overflow-x-scroll-no-scrollbar div * {
overflow-x:auto;
width:100%;
padding-bottom:17px;
white-space: nowrap;
cursor:pointer
}
/* the following classes are only here to make the example looks nicer */
.parent-style {width:100px;background-color:#FF9966}
<div class="parent-style overflow-x-scroll-no-scrollbar">
<div>
<div>This content too long for the container, so it needs to be hidden but scrollable without scrollbars</div>
</div>
</div>
I assuming you want to hide the scrollbar locally. In that i mean, not on a web server for the world to see, but on your local copy of firefox, for your 'viewing pleasure' only.
this is what I've found to work for me on opensuse/kde:
in userChrome.css;
#content browser {
margin-right -12px !important;
overflow-x:hidden;
overflow-y:scroll;
}
use -14px to completely hide vertical-scroll (more if your system theme has wider scroll setting). I use less (10px) to see just a little of it so I can middle-click to jump to a place on the page.
thing that i did, but don't always work, any longer:
in userContent.css
#content browser {
overflow:-moz-scrollbars-none;
}
-or-
html {
overflow: -moz-scrollbars-none;}
}
above used to work, but I now I've lost the mouse-wheel scroll. Only keyboard arrow keys work now.
Hope I understood what you want and this helps.
Landis.
You might be able to use overflow:-moz-hidden-unscrollable -- this worked perfectly for my needs in part because I was already using dragscroll.js.
As I was looking for it myself and this thread is not providing the updated answer, I would provide it for other newcomers as myself.
#element{
scrollbar-width: none;
}

Dynamic Div or assigning multiple functions to a Div in CSS/HTML

I'm relatively new to Web dev. The question is generic, but I'll pose specific user-cases.
Use-case 1:
I have a div element on a web page. When the page loads the first time, this div runs a small 5 sec animation. What I wish to do is, when this animation ends, I want the same div to contain some other element - it could be an image, a link, another animation etc.
That is, one container - the div - hosting multiple elements on a time-scale. First 5 secs animation , followed by an image or a link.
What Javascript methods will allow me to do so?
Use-case 2:
Again, I have a div element in a page. Now this div element is like a tabbed browser - you click on a different tab to view a different web page. Similarly, I wish to make this a "tabbed" div. As in, when the user hovers the mouse on tab 1, the div would show a video, when hovered over tab 2, it would show another video in the same div - that is, replacing the old video. The tabs can be considered as a fancy looking link.
Or, in the first place, is there an alternative to 'div' to do the things mentioned above?
Thanks,
SMK.
Solution for use case 2 -
This is a slightly lengthy solution but its extremely flexible and can be scaled up to any number of tabs very easily
We will divide the solution into 3 parts - The CSS, HTML and JQuery.
Lets take a look at the CSS part first
<style>
#tab_holder {
width: 350px; !important
}
#tab_holder .tabs {
float: left;
height: 20px;
padding: 5px;
border: 1px solid #eee;
border-bottom: none;
width: 50px;
cursor: pointer;
border-radius: 5px 5px 0 0;
}
#tab_holder .tabs:hover {
background-color: #eee;
}
#tab_holder #content_holder {
width: 400px; !important
margin: 0 0 0 0;
border: 1px solid #000;
padding: 10px;
float: left;
border-radius: 0 5px 5px 5px;
}
.content {
visibility: hidden;
}
</style>
Let us now take a look at the HTML part of this solution
<div id="tab_holder">
<div id="tab1" class="tabs">Video1</div>
<div id="tab2" class="tabs">Video2</div>
<div id="tab3" class="tabs">Video3</div>
<div id="content_holder">
<div id="main_content">Select a tab to see the video..</div>
</div>
</div>
<!-- These are divs in which you put your actual content.
They are always hidden -->
<div id="content1" class="content">
<iframe width="200" height="200" src="http://www.youtube.com/embed/4Z6YUGGlwtA?rel=0" frameborder="0" allowfullscreen></iframe>
< /div>
<div id="content2" class="content">
<iframe width="200" height="200" src="http://www.youtube.com/embed/s13dLaTIHSg?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
<div id="content3" class="content">
<iframe width="200" height="200" src="http://www.youtube.com/embed/I1qHVVbYG8Y?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
You can see that each tab is represented by a div which is using the "tabs" class from the CSS section. If you need to add a new tab, all you have to do is add a new div and give is a new id. For example to add a forth tab, you can say -
<div id="tab4" class="tabs">Video4</div>
It is as simple as that.
Now the thing I like about this approach is that you can place the content to be displayed also in div's, rather that nesting it under jquery. In this case we use the div's with the id content1 content2 content3
This gives you the flexibility to expand as you enter content into the div and use normal markup without getting confused and at ease.
These div's are not visible as we have set their visibility to hidden is CSS.
If you add a new tab div you must also add a new content div.
Now we move onto the JQuery part -
$(document).ready(function (){
/* Add the listeners. */
$("#tab1").mouseover(function (){
switch_content('content1')
});
$("#tab2").mouseover(function (){
switch_content('content2')
});
$("#tab3").mouseover(function (){
switch_content('content3')
});
});
function switch_content(name){
$("#main_content").fadeOut('fast',function (){
$("#main_content").html($("#"+name).html());
$("#main_content").fadeIn('fast');
});
}
The above JQuery function is extremely straight forward. Each tab is attached a action listener which is fired by a mousover event. So if you add another tab with the id=tab4 and its respective content div with the id=content4 then all you have to add in the jQuery is:
$("#tab4").mouseover(function (){
switch_content('content4')
});
So it becomes very easy to expand the code.
You can find a working demo of this on my website demo section
Tips -
Avoid using hover because it creates an annoying user experience due to accidental hovers and it is hard for mobile platforms to emulate this event. Most of them fall back to click. So I suggest use the click event instead.
If you must use, make use of the HTML video tag and pause the video using JS if the user hovers on another tab. This will render a better user experience.
Here is an example for use-case 1.
In your html you need to include the 5 second animation, i persume this is a gif? Although it can be any content. For the sake of this example i will show it as a div.
The html i have used:
<div id="example">
<div id="somecontent"> </div>
<div id="morecontent"> </div>
</div>
The CSS:
#example
{
width:500px;
height:500px;
background-color:#f00;
padding:10px;
}
#somecontent
{
width:200px;
height:200px;
background-color:#fff;
}
#morecontent
{
width:200px;
display:none;
height:200px;
background-color:#000;
}
and the javascript(using jQuery):
setTimeout(function() {
$("#somecontent").fadeOut("slow", function() {
$("#morecontent").fadeIn("slow");
});
}, 5000);​
Have a look at this jsfiddle for it in action - http://jsfiddle.net/fntWZ/
For use case 2 it will be more complicated. Try having a look for some different plugins that could help with this
answer for use-case:1
css :
<style>
#myDiv {
height:0;
width:0;
position:absolute;
border:1px solid red;
}
</style>
script :
$(document).ready(function(){
$("#myDiv").animate({width:"100px", height:"100px"},5000, function(){
var image = new Image();
image.src = "dropdownContainerBottomMiddle.png"; //your image src goes here
$("#myDiv").append(image);
//you can append more content by using setTimeout function
setTimeout(function(){
var anc = "stackoverflow";
$("#myDiv").append(anc);
}, 1000);
});
});
html:
<div id="myDiv"></div>