I'm trying to make a simple page where there are several rows of images, each one with a horizontal scrolling (using Nicescroll 3).
Using the mouse, when the horizontal scrolling of the row is finished, the mouse wheel has no function. What I wanted to do is that the page continued scrolling vertically after the horizontal scrolling has finished.
My code:
HTML:
<div id="main-content">
<div class="row">
<div class="square-container">
<div class="square"></div>
</div>
<!-- several other square-container divs -->
<div class="square-container">
<div class="square"></div>
</div>
</div>
<div class="row">
<!-- several other square-container divs -->
</div>
<!-- several other rows -->
</div>
</div>
CSS:
#main-content{
min-height: 100%;
height: auto;
}
#main-content > .row {
overflow-x:scroll;
overflow-y:hidden;
white-space:nowrap;
}
.square-container {
float:none;
display:inline-block;
margin: 20px 30px 5px 30px;
}
.square{
height: 100px;
width: 100px;
border: 1px solid black;
}
Here's my Fiddle
Thanks for feedback.
Added to TODO list.
Issue opened -> https://github.com/inuyaksa/jquery.nicescroll/issues/451
Related
I have been reading about fixed div's within relative and absolute div's here:
Fix position of div with respect to another div
Fixed positioned div within a relative parent div
Fixed position but relative to container
And many other but none can help me to achive a behavior I have seen in few pages (blogs). I can not remember one at the moment, but here are some images to explain
View 1 & View 2
After scrolling down, the contextual menu sticks to the side of the view and moves down with the scrolling until reach the end of the section in which it stops. If there is more content after it, you can keep scrolling down but the contextual menu no longer follow your view. The same going up, you reach the section, the contextual menu follows you up until the start of the section, then stops and you can keep scrolling up.
Is this posible with only HTML and CSS or do I need a plugin?
Here is a jsFiddle piece of code, perphaps incomplete. Forgot to mention, I'm doing this in Angular 6+ as a component, so I don't have full access to the index.html file with the body tag. The jsFiddle shows what I can work with.
There were a few things going on:
You can set body { position: relative } in your CSS
position: sticky needs a full height column to work. Because your col-6 that was holding your menu was only as tall as it needed to be, it won't scroll.
I moved the p-sticky class to your column.
sticky also needs a top value to know where the element should stick to once it becomes sticky.
.p-sticky {
position: sticky;
top: 60px;
}
body {
position: relative;
}
/*some attemps*/
.p-relative {
position: relative;
}
.p-absolute {
position: absolute;
}
.p-sticky {
position: sticky;
top: 60px;
}
.p-fixed {
position: fixed;
}
/* Standar CSS*/
.navbar {
background-color: blue;
width: 100%;
}
.nav-fixed {
top: 0px;
z-index: 1;
position: fixed;
}
.content-ex1 {
height: 200px;
background-color: green;
}
.content-ex2 {
height: 500px;
background-color: #aaaaaa;
}
.menu {
height: 50px;
background-color: red;
}
<div class="navbar">
some navbar things
</div>
<div class="navbar nav-fixed">
some navbar things
</div>
<div class="content-ex1"> Some content here</div>
<div class="container">
<div class="row">
<div class="col-sm-6 p-sticky">
<div class="menu">menu or something</div>
</div>
<div class="col-sm-6 content-ex2"> Some content here</div>
</div>
</div>
<div class="content-ex1"> Some content here</div>
Here's the fiddle to play around with (which includes your bootstrap):
http://jsfiddle.net/w4mz9dte/
Note: you appear to be using an old version of BootStrap. You may want to update to the newest version. In that case, only a few things will change - namely, you move the p-sticky class to the menu.
Here's the newest version of BS 4.4: http://jsfiddle.net/kamr0bjw/
body {
position: relative;
}
/*some attemps*/
.p-relative{
position:relative;
}
.p-absolute{
position:absolute;
}
.p-sticky{
position:sticky;
top: 60px;
}
.p-fixed{
position:fixed;
}
/* Standar CSS*/
.navbar{
background-color: blue;
width:100%;
}
.nav-fixed{
top: 0px;
z-index:1;
position:fixed;
}
.content-ex1{
height:200px;
background-color: green;
}
.content-ex2{
height:500px;
background-color: #aaaaaa;
}
.menu{
height:50px;
background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/js/bootstrap.min.js"></script>
<div class="navbar">
some navbar things
</div>
<div class="navbar nav-fixed">
some navbar things
</div>
<div class="content-ex1"> Some content here</div>
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="menu p-sticky">menu or something</div>
</div>
<div class="col-sm-6 content-ex2"> Some content here</div>
</div>
</div>
<div class="content-ex1"> Some content here</div>
I'm building a site using fullpage.js and Foundation. I'm trying to vertically center an image inside of a section and I'm having no luck.
I've tried this:
https://css-tricks.com/centering-in-the-unknown/
I think that the issue has something to do with the fp-tableCell div that fullpage.js creates.
<div id="first-section" class="section sTop active">
<div id="first-section-row" class="row inner">
<div id="slide_1_wrapper" class="small-12 medium-6 columns">
<h1 class="title">Hello!</h1>
<h2 class="subtitle">My name is Whatever</h2>
</div>
<div id="main-picture-wrapper" class="small-12 medium-6 columns">
<img id="main-picture" src="img/headshot.jpg" alt="my_picture">
</div>
</div>
</div>
I tried the CSS from the article above with no luck:
#main-picture {
max-height: 400px;
}
#main-picture-wrapper {
display: inline-block;
vertical-align: middle;
}
#slide-1-wrapper {
position: relative;
}
#first-section:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em; /* Adjusts for spacing */
}
Screenshot of the rendered html, showing the fp-tableCell
try to add this in html
<div id="page">
<div id="content_container" class="small-12 medium-6 columns">
<div id="main-picture-wrapper">
<img id="main-picture" src="keyboard_search.png" alt="my_picture">
</div>
</div>
</div>
in css
*{ margin:0; padding:0;}
#page{display:table;overflow:hidden;margin:0px auto;}
#content_container{display:table-cell;vertical-align: middle;}
#main-picture-wrapper p{text-align:center;}
html,body{height:100%;}
#page{height:100%;width:100%; max-width:600px; text-align:center;}
.bannerimg{width:100%;max-width:600px;margin:0px auto;}
may help you
By default fullpage.js uses the option verticalCentered:true, so any image you add will be automatically centered unless you change it by using CSS.
You can easily see this in any demo online or in any of the provided examples.
From Michael in the comments:
Try giving the wrapper ID or class position: relative and then the image class or ID position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; - Rough Demo: jsfiddle.net/rrh5c04a
I have a section of my webpage that contains media, mostly pictures. I want the user to be able to re-size the picture to whatever size he/she wants. I was hoping the user would be able to drag a corner to re-size the picture if that is possible.Here is the demo: https://jsfiddle.net/anstw7Lu/ Here is the HTML:
<div id="media-section">
<!--Title -->
<div id="media-title">Media</div>
<div id="media-button" class="button-container">
<!-- The panel that will display the content -->
<div id="media-content"><br><br>
Here is my picture<br><img src="http://circleofdocs.com/wp-content/uploads/2014/10/bigstock-Coconut-isolated-on-white-back-70653349.jpg" height=200px width=200px>
<br> I want to be able to resize this picture, make it larger, smaller, ect.
</div>
</div>
CSS3
You can use a new CSS3 feature called Box Resizing. You should add this to your stylesheet:
img {
resize: both;
overflow: auto;
}
Reference: http://www.w3schools.com/cssref/css3_pr_resize.asp
You might also want to consider using JavaScript, which may have wider browser support. You can use jQuery UI: https://jqueryui.com/resizable/
To create resize element or image from user side, you need to use Resizable which allow you to resize an element
$(function() {
$( "img" ).resizable();
});
#media-section{
float:left;
text-align: center;
height:500px;
width: 250px;
border-style: solid
}
#media-title{
height:6%;
width:100%;
float:left;
font-size:24px;
}
#media-button{
height:4%;
width:100%;
float:left;
border-style: solid;
border-top: none;
border-left: none;
border-right: none;
}
#media{
width:100%;
height:92.5%;
float:left;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div id="media-section">
<!--Title -->
<div id="media-title">Media</div>
<div id="media-button" class="button-container">
<!-- Button that when clicked activates a dalog box for the passage. -->
<button id="max-media" class="max"></button>
</div>
<!-- The panel that will display the content -->
<div id="media-content">
Here is my picture<br><img id="resizable" src="http://circleofdocs.com/wp-content/uploads/2014/10/bigstock-Coconut-isolated-on-white-back-70653349.jpg" height=200px width=200px>
<br> I want to be able to resize this picture, make it larger, smaller, ect.
</div>
</div>
Use a <div> with your image as a background and then allow resizing through CSS.
.image {
width: 130px;
height: 100px;
background-image: url('https://picsum.photos/id/203/130/100');
background-size: contain;
border: 1px solid lightgray;
background-repeat: no-repeat;
resize: both;
overflow: auto;
}
<div class="image"></div>
Note: I am unable to edit the HTML, so I have to find a workaround.
HTML:
<div id="container">
<div id="breadcrumbAds">...</div>
<div id="breadcrumbWrapper">...</div>
<div id="containerTopParsys">...</div>
<div id="leftColWrapper" class="column663Wrapper">...</div>
<div id="rightColWrapper" class="rightColumn663Wrapper">...</div>
<div style="clear:both;"></div>
<div id="containerBottomParsys">...</div>
<div style="clear:both;"></div>
<div id="bgpromo">...</div>
<div style="clear:both;">...</div>
<div style="clear:both;"></div>
</div>
The issue is that all of the divs inside #container, EXCEPT for #leftColWrapper and #rightColWrapper, need to be 100% width of #container, but #leftColWrapper and #rightColWrapper need to be stacked next to each other and centered (together) within the 100% #container, with a max-width of 1224px.
I tried utilizing the following jQuery to add a wrapper div around #left... and #right..., but it ended up grabbing the ads in those containers and placing them in the component where the JS for the page is stored.
(function($) {
$("#leftColWrapper, #rightColWrapper").wrapAll("<div class=\"colWrapper\" />");
})(jQuery);
I either need another solution to wrap those two divs together, so that I can set a max-width of 1224px and center them, or I need to know why this jQuery is picking up those ads and duplicating them within the JS component.
#container{
text-align: center;
font-size: 0;
}
#container > div{
outline: 1px solid #333;
display: inline-block;
min-height: 10px;
text-align: left;
width: 100%;
font-size: 14px;
}
#container #leftColWrapper, #container #rightColWrapper{
width: 50%;
max-width: 612px;
}
<div id="container">
<div id="breadcrumbAds">...</div>
<div id="breadcrumbWrapper">...</div>
<div id="containerTopParsys">...</div>
<div id="leftColWrapper" class="column663Wrapper">width: 50%;<br>
max-width: 612px;</div><div id="rightColWrapper" class="rightColumn663Wrapper">width: 50%;<br>
max-width: 612px;</div>
<div style="clear:both;"></div>
<div id="containerBottomParsys">...</div>
<div style="clear:both;"></div>
<div id="bgpromo">...</div>
<div style="clear:both;">...</div>
<div style="clear:both;"></div>
</div>
I want to stretch the height of my footer to 100% so it stretched its parent footer div to the end of the page. I tried this solution but it didn't work for me.
How can I stretch a div to 100% page height
Whenever I tried to set the height of my footer to 100%, it actually show the same size free area on the bottom of the page. I am using 960 Grid system CSS framework. if its not possible in CSS, can we do this in jquery or javascript?. check the demo of my page DEMO http://jsfiddle.net/23eED/1/ or
Here is my HTML code:
<div class="footer">
<div class="container_16">
<div class="grid_16">
<div class="footer-end-inner">
<div class="grid_6 alpha copyright">
<p>Copy right © <b>Mossawir</b></p>
</div>
<div class="grid_10 omega footernav">
<ul class="nav2">
<li>Home</li>
<li>Menu</li>
<li>Menu</li>
<li>Contact Me</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
and here is my CSS code:
.footer{
height: 150px;
width: 100%;
background-color: #000615;
}
.footer-end-inner{
background-color: #162e4c;
height: 80px;
width: 960px;
}
.footer a{
color: #98999a;
}
.footer p{
color: #98999a;
padding-left:10px;
}
.copyright, .footernav{
margin-top:30px;
}
.footer a:hover {
color: #fff;
text-decoration: none;
}
You have to ensure that the body is not adding some space:
body { margin: 0; padding: 0; }
.footer { margin: 0; }
Also ensures the footer is taking up 100%.
make sure that its parent has set up fixed width like:
<div class="parent" width="300px">
<div class="footer">...</div>
</div>