Separate 2 regions of the screen with their own vertical scrollbar - html

I'm rendering with Angular.js and Bootstrap 2.3.2 a series of thumbnails in the left side of the screen, on the right side I have the larger version, at the moment I'm able to get only one scrollbar, I would like to make them independent with their own vertical scrollbar, without using the frames but only css.
HTML:
<div class="row">
<div class="span3">
<div class="thumbs-list">
<div infinite-scroll='nextThumb()' infinite-scroll-disabled='busyThumb' infinite-scroll- distance='1'>
<div class='thumb' ng-repeat='thumb in arrayOfThumbs'>
<div class="image-thumbnail">
<ul class="scrubber" style="width: 115px; height:auto; padding: 0px;">
<li style="display: block;" ng-click="viewImage(doc)">
<a href="#">
<img ng-src="{{thumb.code}}" alt="" title="Thumb 1"></img>
</a>
</li>
</ul>
</div> <!-- END image-thumbnail -->
</div> <!-- END class='thumb' -->
</div> <!-- END infinite-scroll -->
</div> <!-- END thumb-list -->
</div><!-- END span3 -->
<div class="span12">
<div class="images-list">
<div infinite-scroll='nextImage()' infinite-scroll-disabled='busyImage' infinite-scroll- distance='1'>
<div class='image-page' ng-repeat='image in arrayOfImages'>
<ul class="scrubber-page" >
<li style="display: blockImage;" ng-click="zoom(doc)">
<a href="#">
<img ng-src="{{image.code}}" alt="" title="Page 1"></img>
</a>
</li>
</ul>
</div> <!-- END class='image-page' -->
</div> <!-- END infinite-scroll -->
</div> <!-- END images-list -->
</div> <!-- END span12 -->
</div> <!-- END row -->
CSS:
.thumbs-list {
margin-top: 95px;
position: absolute;
display: block;
padding: 8px;
height: auto;
overflow:auto;
}
.image-thumbnail {
margin-top:15px;
height: auto;
overflow: auto;
text-align: center;
padding: 1em 1em;
border: 1px solid #aaa;
background: #fff;
color: #222;
border-radius: 0px;
-moz-box-shadow: 3px 3px 10px 3px #ccc;
-webkit-box-shadow: 3px 3px 10px 3px #ccc;
box-shadow: 3px 3px 10px 3px #ccc;
}
.images-list {
margin-top: 95px;
position: absolute;
display: block;
padding: 8px;
height: auto;
overflow:auto;
}
.image-page {
margin-top:15px;
height: auto;
overflow: auto;
text-align: center;
padding: 1em 1em;
border: 1px solid #aaa;
background: #fff;
color: #222;
border-radius: 0px;
-moz-box-shadow: 3px 3px 10px 3px #ccc;
-webkit-box-shadow: 3px 3px 10px 3px #ccc;
box-shadow: 3px 3px 10px 3px #ccc;
}
.scrubber-page {
height:auto;
width:auto;
overflow:auto;
}

Did you tried to set a height / width of your elements and add :
overflow: scroll;
Then you will have a scroll bar for each elements with bigger content than their size.

Related

Container Won't Contain Everything

I cannot get my .container{} to encompass all the content on my web page. My lower navigation buttons are sitting outside the container (marked by a 1px black border) and I can't figure out why. I'm not sure where I've went wrong in my CSS or HTML code! Thanks in advance for your help. Here is a link to my CodePen: https://codepen.io/IDCoder/pen/rGWeEE?editors=0100
Here are my code snippets:
<html>
<head>
<title>Ms.Jane Equities Management Corp</title>
</head>
<body>
<div class="container-fluid">
<!-- Top Box -->
<div class="wrap">
<div class="Logos">
<img src="https://s26.postimg.org/iqkxecqnd/Coldwell_Banker-_Logo_RS1.jpg" width="150" height="82"/>
<img src="https://s26.postimg.org/iqkxecqnd/Coldwell_Banker-_Logo_RS1.jpg" width="150" height="82"/> </div>
<div class ="nav wrap">
<!--navigation buttons-->
<ul class="navigation">
<li id="NAV-ONE">LOG IN</li>
<li id="NAV-TWO">BUY A HOME</li>
<li id="NAV-THREE">SELL A HOME</li>
<li id="NAV-FOUR">CONTACT US</li>
</ul>
</div>
</div>
<!-- Middle Box -->
<div class="row two">
<div>
<div class="floater box">
<!--<div class="search box wrap">
<div class="search">
<input type="text" class="searchTerm" placeholder="What are you looking for?">
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
</div>-->
</div>
</div>
</div>
<!-- Bottom Box -->
<div class="row three">
<div class ="nav wrap 2">
<!--navigation buttons-->
<ul class="navigation">
<li id="NAV-A">MY LISTINGS</li>
<li id="NAV-B">COMMUNITIES SERVED</li>
<li id="NAV-C">PROPERTIES</li>
</ul>
</div>
</div>
</div>
</body>
<html>
CSS:
.container-fluid{
border: 1px solid #000000;
max-width: 1600px;
/*overflow: hidden;*/
}
.wrap{
background-color: yellow;
display: inline: flex;
/*overflow: hidden;*/
}
.Logos{
width: 55%;
display: inline-block;
background-color: blue;
}
.nav.wrap{
display: inline-block;
background-color: green;
float: right;
margin-top: 25px;
}
ul.navigation{
font: bold 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
/*text-align center;*/
/*border: 1px solid green;*/
/*overflow: hidden;*/
}
.navigation li {
display: inline-block;
}
.navigation a {
background: #395870;
background: linear-gradient(#49708f, #293f50);
border-right: 1px solid rgba(0, 0, 0, .3);
color: #fff;
padding: 12px 20px;
text-decoration: none;
}
.navigation a:hover {
background: #314b0;
box-shadow: inset 0 0 10px 1px rgba(0, 0, 0, .3);
}
.navigation li:first-child a {
border-radius: 4px 0 0 4px;
}
.navigation li:last-child a {
border-right: 0;
border-radius: 0 4px 4px 0;
}
.row.two{
background-image: url(https://s1.postimg.org/5gvbly4hin/East_Hyde_Park_Chicago_aerial_0470.jpg);
background-position: absolute;
background-size:cover;
background-repeat: no-repeat;
max-width: 1600px;
height: 550px;
margin: auto;
}
.floater.box{
background-color: white;
border-radius: 10px;
opacity: .45;
max-width: 75%;
height: 200px;
position: absolute;
top:50%;
left: 0;
right: 0;
margin: auto;
}
/*.search {
width: 50%;
position: relative
}
.searchTerm {
float: left;
width: 100%;
border: 3px solid #00B4CC;
padding: 5px;
height: 20px;
border-radius: 5px;
outline: none;
color: #9DBFAF;
}
.searchTerm:focus{
color: #00B4CC;
}
.searchButton {
position: absolute;
right: -50px;
width: 40px;
height: 36px;
border: 1px solid #00B4CC;
background: #00B4CC;
text-align: center;
color: #fff;
border-radius: 5px;
cursor: pointer;
font-size: 20px;
}
.search.box.wrap{
width: 30%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
*/
I think your div.nav.wrap is getting pushed down because it's floated and there's no room for it in the container and because it's floated the container doesn't adjust for it. If you remove the float, you'll see the container start to contain it. That's normal float behaviour - elements with float are out of the 'flow' of the document so other elements aren't affected by them.
I'd just add a negative top margin to push it back up. I'd usually do this in rem or depending on how you size the nav height. So your existing .nav.wrap rule would become:
.nav.wrap{
display: inline-block;
background-color: green;
float: right;
margin-top: -35px;
}

CSS margin connected?

Below print screen from google chrome html/css view.
One element under another, margin: 10px;, so they should be 20px from each other.
But they aren't. They are 10px apart, like the margins are connected.
body {
margin: 0;
background-image: url("2.png");
background-repeat: repeat-x;
font-family: 'Verdana';
font-size: 17px;
}
#logo {
background-image: url("logo.png");
width: 527px;
height: 58px;
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
margin-top: 7px;
}
.hidden {
display: none;
}
.nav {
background-color: #55585d;
height: auto;
margin-top: 10px;
border-bottom: 2px solid #44474c;
border-top: 2px solid #44474c;
text-align: center;
}
.nav > ul {
list-style: none;
margin: 0px;
padding: 0px;
}
.nav > ul li {
display: inline-block;
padding: 5px;
margin-right: 30px;
font-weight: 700;
}
/* 1195px width */
#center {
width: 1195px;
margin-left: auto;
margin-right: auto;
}
#container {
width: 864px;
min-height: 500px;
margin-left: 16px;
float: left;
}
.post {
width: 392px;
height: 453px;
box-shadow: 3px -3px 6px 0px #000000,
-1px 1px 1px 0px #000000;
margin: 10px;
float: left;
}
#aside {
width: 315px;
float: left;
min-height: 500px;
}
.abox1 {
margin: 10px;
width: 279px;
height: 453px;
box-shadow: 3px -3px 6px 0px #000000,
-1px 1px 1px 0px #000000;
}
<!DOCTYPE html>
<html lang="pl">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="utf-8">
<title>Devloger</title>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<div id="logo"></div>
<h1 class="hidden">Devloger</h1>
<nav>
<div class="nav">
<ul>
<li>
Strona Główna
</li>
<li>
Kategorie
</li>
<li>
Spis Treści
</li>
<li>
Współpraca
</li>
<li>
Kontakt
</li>
</ul>
</div>
</nav>
</header>
<div id="center">
<main>
<div id="container">
<div class="post">
</div>
<div class="post">
</div>
<div class="post">
</div>
<div class="post">
</div>
<div class="post">
</div>
<div class="clear" style="clear: both;"></div>
</div>
</main>
<aside>
<div id="aside">
<div class="abox1">
</div>
<div class="abox1">
</div>
<div class="abox1">
</div>
</div>
</aside>
</div>
<div class="clear" style="clear: both;"></div>
</body>
</html>
There are cases (you can read about it here) where margins between elements are collapsed (overlapped, one on top of the other), and this is an intended behaviour, so it's not an error.
This is one of these cases and your current issue:
Adjacent siblings
The margins of adjacent siblings are collapsed (except when the later sibling needs to be cleared past floats).
First you have some .post blocks with that margins, but these margins are working well because that blocks are floated. If you remove float: left from .post class you will see that these blocks margins are collapsed as well.
Knowing that margin collapsing exists, you can take it into account when designing layouts:
Page flow goes from left to right, top to bottom. So instead of define a margin-top and margin-bottom, define only a margin-bottom.
aside {
width: 315px;
float: left;
min-height: 500px;
}
.abox1 {
margin: 0 10px 20px 10px;
width: 279px;
height: 453px;
box-shadow: 3px -3px 6px 0px #000000,
-1px 1px 1px 0px #000000;
}
<aside>
<div class="abox1"></div>
<div class="abox1"></div>
<div class="abox1"></div>
</aside>

Moving element outside of grid system

I'm developing a tumblr theme with bootstrap, and I'd like a nice big area for the user's profile picture right next to the header. The issue here is, that bootstrap has a very tight grid format and I can't see any room for what I want:
see that red thing? I want to move it where the blue arrow is pointing. I've tried expanding the container, setting the red circle to float left, and giving it margin-bottom:100%, but that shoved everything down off the page.
Here's my css and HTML for reference, the item in question is labeled with the class "talkbubble":
CSS
//Media Queries
#media (min-width: 1200px){
.container {
width: 800px;
}
}
#media (min-width: 992px){
.container {
width: 800px;
}
}
//Header Edits
.jumbotron{
margin-bottom: 0px;
h1{
color: red;
}
}
//upsidedown tab edits
.tab-content{
padding:10px;
border:1px solid #ddd;
border-bottom:0px;
}
.nav-tabs {
border-bottom: 0px;
border-top: 1px solid #ddd;
}
.nav-tabs > li {
margin-bottom:0;
margin-top:-1px;
margin-left: 32px;
width: 71px;
white-space: nowrap;
}
.nav-tabs > li > a {
padding-top: 8px;
padding-bottom: 8px;
line-height: 20px;
border: 1px solid transparent;
background-color: #eee;
-moz-border-radius:0px;
-webkit-border-radius:0px;
border-radius:0px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
border-bottom-right-radius: 10px;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
color: #555555;
cursor: default;
background-color: #eee;
border: 1px solid #ddd;
border-top-color: transparent;
}
.nav-tabs > li.active > a {
background-color: #eee !important;
}
.arrow {
border-color: #eee transparent transparent #eee;
border-style: solid;
border-width: 17px 17px 17px 17px;
height:0;
width:0;
position:absolute;
bottom:2px;
right:-33px;
}
.arrow2 {
border-color: #eee #eee transparent transparent;
border-style: solid;
border-width: 17px 17px 17px 17px;
height:0;
width:0;
position:absolute;
bottom:2px;
right:67px;
}
//square gallery
.square{
border-radius: 20px;
border-style: solid;
border-width: 2px;
width: 200px;
height: 200px;
margin-top: 60px;
}
//iconbubble
.talkbubble {
width: 120px;
height: 120px;
background: red;
position: absolute;
-moz-border-radius: 60px;
-webkit-border-radius: 60px;
border-radius: 60px;
}
.talkbubble:before {
content:"";
position: absolute;
right: 100%;
top: 50px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid red;
border-bottom: 13px solid transparent;
}
HTML below
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/app.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap/tab.js"></script>
<script src="js/jquery.fakecrop.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-pinterest-extension-installed="cr1.39.1">
<div class="container">
<div class="talkbubble"></div>
<div class="header clearfix">
<!--
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active">Home</li>
<li role="presentation">About</li>
<li role="presentation">Contact</li>
</ul>
</nav>
-->
<h3 class="text-muted">Hi I'm...</h3>
</div>
<div class="jumbotron tab-content">
<div id="home" class="tab-pane fade in active">
<h1>CpBunni</h1>
<p class="lead">...and I'm an artist.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h1>CpBunni</h1>
<p class="lead">...and I'm a cosplayer.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h1>CpBunni</h1>
<p class="lead">...and I'm a nude model.</p>
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home <div class="arrow"></div><div class="arrow2"></div></a></li>
<li><a data-toggle="tab" href="#menu1">Menu 1 <div class="arrow"></div><div class="arrow2"></div></a></li>
<li><a data-toggle="tab" href="#menu2">Menu 2 <div class="arrow"></div><div class="arrow2"></div></a></li>
</ul>
<script>
$(document).ready(function () {
// for a filled square thumbnail
$('.square img').fakecrop({fill: true, wrapperWidth: 200, wrapperHeight: 200});
});
</script>
<div class="row marketing">
<div class="col-sm-4">
<div class="square"><img src="resources/testimg.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg2.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg3.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg4.png" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg5.jpg" alt="..."></div>
</div>
</div>
<footer class="footer">
<p>© 2015 Company, Inc.</p>
</footer>
</div> <!-- /container -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="./Narrow Jumbotron Template for Bootstrap_files/ie10-viewport-bug-workaround.js"></script>
<div id="scrollrail-vertical" class="disabled" style="width: 12px; border-left-width: 1px;"><div id="scrollbar-vertical" style="visibility: hidden; border-radius: 5px 7px; box-shadow: rgba(255, 255, 255, 0.901961) 0px 0px 1px 1px; height: 1015px; top: 2px; opacity: 0;"></div></div><div id="scrollrail-horizontal" class="disabled" style="height: 12px; border-top-width: 1px;"><div id="scrollbar-horizontal" style="visibility: hidden; border-radius: 14px 10px; box-shadow: rgba(255, 255, 255, 0.901961) 0px 0px 1px 1px; width: 1916px; left: 2px; opacity: 0;"></div></div><div id="window-resizer-tooltip"><span class="tooltipTitle">Window size: </span><span class="tooltipWidth" id="winWidth"></span> x <span class="tooltipHeight" id="winHeight"></span><br><span class="tooltipTitle">Viewport size: </span><span class="tooltipWidth" id="vpWidth"></span> x <span class="tooltipHeight" id="vpHeight"></span></div></body>
</html>
See this fiddle
The trick is this:
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
...your image markup here...
</div>
<div class="col-md-9">
...
</div>
</div>
I've set it to be like that from md up. You might want to make use of hidden-* for the image column at lower widths as what you're doing from a design point of view would look strange at mobile widths.
The absolute position is a right way for your issue. But you have to use another properties instead of float:
top
bottom
left
right
For absolutely positioned elements (those with position: absolute or position: fixed), it specifies the distance between the margin edge of the element and the edge of its containing block.
For relatively positioned elements (those with position: relative), it specifies the amount the element is moved below its normal position.
You can apply this properties directly to the bubble instead of the before: pseudo-element.
Use /* */ instead of // for comments in CSS. For example:
/* iconbubble */
.talkbubble {
position: absolute;
top: 100px;
left: 20px;
z-index: 20;
}
Please check the result:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
/* Media Queries */
#media (min-width: 1200px) {
.container {
width: 800px;
}
}
#media (min-width: 992px) {
.container {
width: 800px;
}
}
/* Header Edits */
.jumbotron {
margin-bottom: 0px;
h1 {
color: red;
}
}
/* upsidedown tab edits */
.tab-content {
padding: 10px;
border: 1px solid #ddd;
border-bottom: 0px;
}
.nav-tabs {
border-bottom: 0px;
border-top: 1px solid #ddd;
}
.nav-tabs > li {
margin-bottom: 0;
margin-top: -1px;
margin-left: 32px;
width: 71px;
white-space: nowrap;
}
.nav-tabs > li > a {
padding-top: 8px;
padding-bottom: 8px;
line-height: 20px;
border: 1px solid transparent;
background-color: #eee;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
border-bottom-right-radius: 10px;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.nav-tabs > .active > a,
.nav-tabs > .active > a:hover,
.nav-tabs > .active > a:focus {
color: #555555;
cursor: default;
background-color: #eee;
border: 1px solid #ddd;
border-top-color: transparent;
}
.nav-tabs > li.active > a {
background-color: #eee !important;
}
.arrow {
border-color: #eee transparent transparent #eee;
border-style: solid;
border-width: 17px 17px 17px 17px;
height: 0;
width: 0;
position: absolute;
bottom: 2px;
right: -33px;
}
.arrow2 {
border-color: #eee #eee transparent transparent;
border-style: solid;
border-width: 17px 17px 17px 17px;
height: 0;
width: 0;
position: absolute;
bottom: 2px;
right: 67px;
}
/* square gallery */
.square {
border-radius: 20px;
border-style: solid;
border-width: 2px;
width: 200px;
height: 200px;
margin-top: 60px;
}
/* iconbubble */
.talkbubble {
position: absolute;
top: 100px;
left: 20px;
z-index: 20;
width: 120px;
height: 120px;
background: red;
-moz-border-radius: 60px;
-webkit-border-radius: 60px;
border-radius: 60px;
}
.talkbubble:before {
content: "";
position: absolute;
right: 100%;
top: 50px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid red;
border-bottom: 13px solid transparent;
}
<div class="container">
<div class="talkbubble"></div>
<div class="header clearfix">
<!--
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active">Home</li>
<li role="presentation">About</li>
<li role="presentation">Contact</li>
</ul>
</nav>
-->
<h3 class="text-muted">Hi I'm...</h3>
</div>
<div class="jumbotron tab-content">
<div id="home" class="tab-pane fade in active">
<h1>CpBunni</h1>
<p class="lead">...and I'm an artist.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h1>CpBunni</h1>
<p class="lead">...and I'm a cosplayer.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h1>CpBunni</h1>
<p class="lead">...and I'm a nude model.</p>
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home <div class="arrow"></div><div class="arrow2"></div></a></li>
<li><a data-toggle="tab" href="#menu1">Menu 1 <div class="arrow"></div><div class="arrow2"></div></a></li>
<li><a data-toggle="tab" href="#menu2">Menu 2 <div class="arrow"></div><div class="arrow2"></div></a></li>
</ul>
<div class="row marketing">
<div class="col-sm-4">
<div class="square"><img src="resources/testimg.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg2.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg3.jpg" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg4.png" alt="..."></div>
</div>
<div class="col-sm-4">
<div class="square"><img src="resources/testimg5.jpg" alt="..."></div>
</div>
</div>
<footer class="footer">
<p>© 2015 Company, Inc.</p>
</footer>
</div> <!-- /container -->

Sticky navigation hidden until scrolling down page

I'm running into an issue where I have two navigation menu's on the same page. I want both to be shown separately in which one involves being a sticky navigation. I want this one hidden until I scroll down and cant see the other that appears. Is there a way we can make this work?
<!-- Start Sticky Navigation -->
<nav id="mainnav">
<div class="container">
<div class="row">
<div class="span4">
<img src="img/logo2.png" alt="LOGO">
</div>
<div class="span8">
<ul id="fluid-nav" class="fluid-navigation visible-desktop">
<li class="current">Top</li>
<li>Overview</li>
<li>Gallery</li>
<li>No Compromises</li>
<li><button class="btnbuy small">Select & Buy</button></li>
</ul>
</div>
</div>
</div>
</nav>
<!-- End Sticky Navigation -->
CSS
nav#mainnav {
width: 100%;
height: 50px;
background-color: #cb0000;
overflow: hidden;
position: relative;
z-index: 999;
}
I Dont Actually get the full detail of what u What but this is Something i came up with
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="main">
</div>
<div id="float">
<div class="m">menu1</div>
<div class="m">menu2</div>
<div class="m">menu3</div>
<div class="m">menu4</div>
</div>
<div class="foot">
<div class="m">menu1</div>
<div class="m">menu2</div>
<div class="m">menu3</div>
<div class="m">menu4</div>
</div>
<div class="main">
</div>
</div>
</div>
Here is the Css
<style type="text/css">
#float{
background: #09C;
position:absolute;
right:60px;
top:20px;
width:90%;
padding:10px;
border-radius: 6px;
-webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
-moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
}
.m{
display: inline-block;
}
.float_content_head{
padding:10px;
border-bottom: 1px solid #efefef;
text-align:center;
}
.float_content{
padding-top:10px;
}
.main{
height: 800px;
margin: 0 auto;
border:1px solid #efefef;
padding: 10px;
background:#ccc;
}
.foot{
background:#09F;
width: 90%;
margin: 0 auto;
border:1px solid #efefef;
padding: 10px;
border-radius: 6px;
-webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
-moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.43);
}
#box p{
margin:0;
padding:0;
}
</style>
And .js
<script type="text/javascript">
$(document).ready(function() {
var starting_position = $('#float').offset();
var top_padding = 20; // Distance from top while scrolling
var bottom_limit = $('.foot').offset();
var box_height = $('#float').height() + 15; // Distance from top
$(window).scroll(function(){
var top_window = $(window).scrollTop();
if (top_window > starting_position.top && top_window < bottom_limit.top - box_height){
$('#float').stop().animate({top: top_window - starting_position.top + top_padding}, 0); //0 makes it sticky
} else if (top_window > bottom_limit.top - starting_position.top - box_height){
$('#float').stop().animate({top: bottom_limit.top - starting_position.top - box_height }, 0);
} else { $('#float').stop().animate({top: 10 }, 400);
}
});
});
</script>
And fiddle Here
You can do this easily by using position:sticky for your headers.
Here is my code:
nav {
position: sticky;
top: 0
}
/* This just makes your navbar look good as I didn't know what library you were using. */
.fluid-navigation {
margin: 0;
padding: 0;
}
.fluid-navigation li {
display: inline;
padding-left: 0.3em;
margin: 0;
}
.row {
display: flex;
flex-direction: row;
}
nav {
background: #222;
padding: 1em 0.5em;
}
.contentBody {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 200vh;
}
a {
color: yellow
}
a:hover {
color: royalblue
}
body {
padding: 0;
margin: 0;
<body>
<div class="content">
<nav id="mainnav">
<div class="container">
<div class="row">
<div class="span4">
<img src="img/logo2.png" alt="LOGO">
</div>
<div class="span8">
<ul id="fluid-nav" class="fluid-navigation visible-desktop">
<li class="current">Top</li>
<li>Overview</li>
<li>Gallery</li>
<li>No Compromises</li>
<li><button class="btnbuy small">Select & Buy</button></li>
</ul>
</div>
</div>
</div>
</nav>
Scroll to the bottom
<div class="contentBody">Content 1<br>Keep Scrolling<br>Content 1<br></div>
</div>
This Navbar will push the top navbar and take its place.
<div class="content">
<nav id="mainnav">
<div class="container">
<div class="row">
<div class="span4">
<img src="img/logo2.png" alt="LOGO2">
</div>
<div class="span8">
<ul id="fluid-nav" class="fluid-navigation visible-desktop">
<li class="current">Top2</li>
<li>Overview2</li>
<li>Gallery2</li>
<li>Compromises2</li>
<li><button class="btnbuy small">Select & Buy</button></li>
</ul>
</div>
</div>
</div>
</nav>
Scroll to the bottom
<div class="contentBody">Content 2<br>Keep Scrolling<br>Peace 🖖.<br></div>
</div>
Hope this helps.
Peace 🖖.

how to align text in div

Im trying to display 4 pictures with a title, description and a delete link on it. I cannot get the link to float right in the box I have.
here's the html
<div id="container">
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
<span class="img-info alignright">Delete</span>
</div>
</div>
</div><!--end container -->
here's the css
#container {
width: 50%;
}
.image-wrapper {
display: inline-block;
width:200px;
padding: 10px;
}
#image-container {
color: #898989;
background:#F9F9F9;
border: solid 1px #ddd;
border-radius:10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
-webkit-box-shadow: 0px 0px 10px #888;
margin:5px auto;
padding:5px;
width:200px;
}
.img-info {
display: block;
}
.alignleft {
float:left;
}
.alignright {
float:right;
}
The html of the picture box gets repeated 3 more times. How can I get the third span link float to the left? Any help would be great.
Adding margin-top: -29px; should achieve this.
DEMO http://jsfiddle.net/4RZJx/1
HTML:
<div id="container">
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
<span class="img-info">Delete</span>
</div>
<span class="img-info alignright">Delete</span>
</div>
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
<span class="img-info">Description:</span>
</div>
<span class="img-info alignright">Delete</span>
</div>
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
</div>
<span class="img-info alignright">Delete</span>
</div>
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
</div>
<span class="img-info alignright">Delete</span>
</div>
</div><!--end container -->
CSS:
#container {
width: 50%;
}
.image-wrapper {
display: inline-block;
width:200px;
padding: 10px;
}
#image-container {
color: #898989;
background:#F9F9F9;
border: solid 1px #ddd;
border-radius:10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
-webkit-box-shadow: 0px 0px 10px #888;
margin:5px auto;
padding:5px;
width:200px;
}
.img-info {
display: block;
}
.alignleft {
clear: both;
float:left;
}
.alignright {
float:right;
margin-top: -29px;
}
First of all, where are you using .alignleft in your code provided?
Secondly, the .alignright span has two classes: img-info and alignright. For img-info you have display-block. This is redundant, as the float property will make an element display-block.
All you need to do is add overflow: hidden to your main div (image-container). The float applied to the link makes it act as though it's not in the same "layer". Adding overflow-hidden will fix this problem. Jsfiddle - http://jsfiddle.net/piedoom/6jTyD/
Try this really quick fix, however, you may want to modify the widths and such:
DEMO: http://jsfiddle.net/4RZJx/
<div id="container">
<div class="image-wrapper">
<div id="image-container">
<img src="gallery_traditional_1.jpg" width="200" height="100"><br>
<div class="info-container">
<div class="alignleft">
<span class="img-info">Title:</span>
<span class="img-info">Description:</span>
</div>
<span class="img-info alignright">Delete
</span>
</div>
</div>
</div>
</div><!--end container -->
CSS:
#container {
width: 50%;
}
.image-wrapper {
display: inline-block;
width:200px;
padding: 10px;
}
#image-container {
color: #898989;
background:#F9F9F9;
border: solid 1px #ddd;
border-radius:10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
-webkit-box-shadow: 0px 0px 10px #888;
margin:5px auto;
padding:5px;
width:200px;
}
.info-container{
overflow: hidden;
}
.img-info {
display: block;
}
.alignleft {
float:left;
}
.alignright {
float:right;
}
Use text-align:
.alignleft {
text-align: left;
}
.alignright {
text-align: right;
}
float is better used for when you want a image to go to the right, and want text to flow around it etc. As it also cause other layout problems, you might as well try text-align.
http://jsfiddle.net/4RZJx/3/