Tile divs equal height on last row of div - javascript

Hello guys is there a way around to achieved the following design?
i make a design of my div but i don't know how to get it like this.divs are in the center of the page and the width of the wrapper of all this divs can be adjust.
Normal content
When the wrapper becomes smaller then it will be a two column div and the last are still equal.
* wrapper div adjust its width when zoom in and zoom out..
CODE
<html>
<head>
<title></title>
<link rel="stylesheet" href="view/css/ui-layout.css" type="text/css"/>
<link rel="stylesheet" href="view/css/layout.css" type="text/css"/>
<script type="text/javascript" src="view/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="view/js/equalheight.js"></script>
<style>
html,body{
padding: 0;
margin:0;
min-width: 820px;
color: #333333;
background-color: #F1F1f1;
font-family: Arial, Helvetica, Sans-Serif;
font-style: normal;
font-weight: normal;
font-size: 13px;
}
a{
text-decoration:none;
color:#3EA7bb;
cursor: pointer;
}
ul{
display: inline-block;
position: relative;
}
hr{
border:1px solid #f1f1f1;
}
.cleared
{
display:block;
clear: both;
float: none;
margin: 0;
padding: 0;
border: none;
font-size: 0;
height:0;
overflow:hidden;
}
.reset-box
{
overflow:hidden;
display:table;
}
#main-container{
width: 80%;
min-height: 100%;
min-width: 820px;
max-width: 1000px;
z-index: 0;
left: 0;
top: 0;
cursor:default;
overflow:hidden;
background-color:#FFFFFF;
position: relative;
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
-moz-box-shadow: 0 0 0 5px #333333;
-webkit-box-shadow: 0 0 0 5px #333333;
box-shadow: 0 0 5px #333333;
}
#header{
height: 100px;
padding-top: 5px;
margin:0 auto;
}
#header-logo{
width: 308px;
height: 100px;
background-image: url(../images/skerp.png);
background-position: center;
background-repeat: no-repeat;
margin-left: 20px;
}
#menu-bar{
margin:0 auto;
min-height: 25px;
z-index: 100;
margin-top: 0;
margin-bottom: 0;
border-radius:0px;
/*-moz-box-shadow: 0 0 0 3px #333333;
-webkit-box-shadow: 0 0 0 3px #333333;
box-shadow: 0 0 3px #333333;*/
-moz-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
margin:0 auto;
}
#menu-wraper{
display: inline-block;
float: right;
margin-right: 10px;
}
.menu-element{
min-width: 75px;
height: 25px;
display:inline-block;
cursor: pointer;
text-align:center;
}
#body-container{
margin:0 auto;
padding-bottom: 90px;
}
.left-container,.right-container,.center-container{
display: block;
float:left;
}
.featured{
margin:20px auto;
padding:5px;
-moz-box-shadow: 0 0 0 5px #333333;
-webkit-box-shadow: 0 0 0 5px #333333;
box-shadow: 0 0 5px #333333;
border-radius: 5px;
min-height: 300px;
width: 780px;
}
.left
{
text-align: left;
}
.left span{
float:left;
left:0;
}
.right
{
text-align: right;
}
.right span{
right:0;
float:right;
}
.main-under-color{
width: 300px;
height:5px;
display: block;
}
.sub-under-color{
width: 100px;
height:5px;
display: block;
}
.content-wrapper{
margin:10px auto;
min-width: 810px;
/*padding:10px;*/
}
.content-wrapper h1{
text-align: left;
}
.image-wrapper{
margin: 0 auto;
}
.page-title{
padding: 20px 10px 10px 10px;
display: block;
}
.page-title h1{
font-weight: bold;
font-size: 40px;
text-indent: 20px;
}
.content-title h1{
font-weight: bold;
font-size: 20px;
}
.content{
padding:0px;/* 15px 15px 15px;*/
display: block;
font-size: 15px;
}
.content p{
text-align: justify;
line-height: 25px;
word-spacing: 1px;
word-wrap:break-word;
}
.border{
-moz-box-shadow: 0 0 0 5px #999999;
-webkit-box-shadow: 0 0 0 5px #999999;
box-shadow: 0 0 5px #999999;
border-radius: 5px;
border:1px solid #999999;
}
.border-top{
border-top:1px solid #999999;
}
.border-left{
border-left:1px solid #999999;
}
.border-right{
border-right: 1px solid #999999;
}
.border-bottom{
border-bottom: 1px solid #999999;
}
.column-wrapper{
padding-top: 20px;
text-align: center;
vertical-align:middle;
width:100%;
}
.column-wrapper div{
display: inline-table;
margin:2px;
}
.column-small{
padding:10px;
padding-bottom:30px;
width:30%;
min-width: 250px;
position: relative;
}
.fixedbottomReadMore{
position: absolute;
bottom: 10px;
right: 20px;
}
.fluedbottomReadMore{
position: absolute;
float:right;
right:20px;
}
.column-small ul{
margin-top: -10px;
width: 100%;
max-width: 240px;
}
.column-small ul li{
text-align: left;
}
.column-small li{
list-style: none;
padding: 5px;
text-indent: -30px;
word-wrap: break-word;
}
.column-medium{
padding:10px;
width: 61%;
min-width: 505px;
}
.column-large{
padding:10px;
width: 100%;
min-width: 760px;
}
</style>
</head>
<body>
<div id="main-container">
<div id="body-container" >
<div class="content-wrapper ">
<div class="cleared"></div>
<div class="content ">
<div class="cleared"></div>
<div class="column-wrapper ">
<div class="column-large ">
</div>
</div>
<div class="cleared"></div>
<div class="column-wrapper">
<div class="column-small border border-top">
<h3>Features</h3>
<ul>
<li>Code blocking</li>
<li>Code Wrapping</li>
<li>Code Killing</li>
<li>Code Sleeping</li>
</ul>
<span class="fixedbottomReadMore">Read more</span>
</div>
<div class="column-small border border-top">
<h3>Modules</h3>
<ul>
<li>Barking Around The house</li>
<li>Loving the Cats</li>
<li>Floating The points</li>
<li>Coding The Sleepers</li>
<li>Coding The Sleepers</li>
</ul>
<span class="fixedbottomReadMore">Read more</span>
</div>
<div class="column-small border border-top">
<h3>Idont knows</h3>
<span class="fixedbottomReadMore">Read more</span>
</div>
<div class="column-small border border-top">
<h3>Modules</h3>
<ul>
<li>Barking Around The house</li>
<li>Loving the Cats</li>
<li>Floating The points</li>
<li>Coding The Sleepers</li>
<li>Coding The Sleepers</li>
</ul>
<span class="fixedbottomReadMore">Read more</span>
</div>
<div class="column-small border border-top">
<h3>Idont knows</h3>
<span class="fixedbottomReadMore">Read more</span>
</div>
</div>
</div>
</div>
<script>
$('.column-wrapper .column-small').equalHeightColumns();
</script>
</div>
<div class="cleared reset-box"></div>
</div>
</body>
</html>

I don't know whether this fits your scenario, however, the fiddle below sligns the bottoms of the DIV.
The thing I am unsure about is, when you convert it to two column model, what all blocks will be visible, if you end up showing two blocks in the last row, then the bottoms will get aligned to bottom.
See if this helps - http://jsfiddle.net/AUV7J/
Making the span as display: table-cell, we can vertically align the block inside it to the bottom
Update:
As you said, you don't want spaces in between. You will have to programatically adjust the size of the last DIV for each column
See the updated Fiddle
Update:
For dynamic columns, see this

I would bind a function to the window resize event like so...
var $win = $(window),
maxHeight,
mode,
calcMaxHeight = function() {
var h = $(this).height();
if (h > maxHeight) {
maxHeight = h;
}
},
adjustDivHeights = function() {
var $col = $(this);
if ($col.height() < maxHeight) {
var $lastChild = $col.children().last();
$lastChild.height(maxHeight - ($col.height() - $lastChild.height()));
}
};
$win.resize(function() {
if ($win.width() > 500) {
if (mode === 'large') return;
mode = 'large';
maxHeight = 0;
$('#container').children().each(calcMaxHeight).each(adjustDivHeights);
} else {
if (mode === 'small') return;
mode = 'small';
maxHeight = 0;
// other size logic
}
});
The event only fires the calculations if/when you switch modes, for efficiency sake, of course.

You can set the height of every last content base on the browser's window since you have a fixed number of contents horizontally, you can make a calculations and make it handy for the last contents. That's my best idea i get so far.

Related

How can I grey out page except for one element?

How can I make a greyed out overlay on a page, but have one element in that page not greyed out?
There are many questions like this asked but none of them work:
Hide all elements except one div for print view - This one does not work for my situation as I do not want to hide everything.
Disable everything except a DIV element - This one the second answer seems similar to mine. But even if I change z-index of my desired ungreyed out element the whole page stays greyed out. Also, I found no difference between using div and iframe.
Want to make the whole page in grayscale except specified div - This one just makes everything else greyscale but I do not want that.
From the example below I want everything greyed out except for <input class="edit-title" value="Site Title">. Right now my code greys out most of the page, I can grey out the whole page if I change
.overlay {
z-index: -1;
}
to
.overlay {
z-index: 0;
}
Is there a way to grey out everything except <input class="edit-title" value="Site Title">?
html {
box-sizing: border-box;
}
.overlay {
top: 0;
bottom: 0;
right: 0;
left: 0;
position: absolute;
background: rgba(0, 0, 0, .4);
z-index: -1;
}
edit-title {
z-index: 100;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body,
input,
optgroup,
select,
textarea {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
body {
font-size: 13px;
line-height: 1.4;
color: #555;
margin: 0;
padding: 0;
background: white;
overflow-x: hidden;
}
.button {
font-weight: bold;
color: #fff;
border: 1px solid #44aa76;
border-width: 0 0 3px 0;
background-color: #66cc98;
padding: 5px;
border-radius: 6px;
text-align: center;
}
.button:focus,
.button:hover,
.active {
cursor: pointer;
background-color: #44aa76;
color: #fff;
outline: none;
}
header {
width: 100%;
border-bottom: 1px solid #eee;
display: flex;
justify-content: center;
padding: 30px 0 10px;
margin-bottom: 10px;
}
input {
font-size: 13px;
border: 1px solid #eee;
border-radius: 4px;
padding: 8px;
}
input:focus {
outline: none;
border-color: #ddd;
}
[type="search"] {
-webkit-appearance: textfield;
}
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
.search {
display: flex;
align-items: center;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
.search input[type="search"] {
width: 100%;
}
label {
font-size: 13px;
margin-right: 5px;
}
.save-button {
width: 30px;
height: 30px;
line-height: 27px;
padding: 0;
margin: 0 10px;
}
h1 {
margin: 0;
padding: 0;
line-height: 1;
font-size: 22px;
padding: 4px 0;
}
.container {
position: relative;
padding: 0 15px;
width: 360px;
max-width: 100%;
margin: 0;
}
.reading-list {
margin-bottom: 15px;
}
.reading-item {
border-radius: 3px;
padding: 0;
margin: 10px 0 0 0;
background-color: #f7f7f7;
position: relative;
overflow: hidden;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 2px 3px rgba(0, 0, 0, 0.05);
transition: all 0.5s ease 0s;
}
.reading-item .item-link {
text-decoration: none;
display: block;
width: 100%;
color: #555;
padding: 10px 50px 10px 56px;
min-height: 56px;
}
.reading-item .item-link:focus,
.reading-item .item-link:hover {
color: #66cc98;
background-color: #fff;
}
.reading-item .item-link span {
display: block;
}
.reading-item .item-link span.title {
font-weight: bold;
}
.reading-item .favicon {
position: absolute;
top: 10px;
left: 10px;
width: 36px;
height: 36px;
border-radius: 4px;
border: 1px solid #ccc;
padding: 1px;
}
.reading-item .item-link:hover .favicon {
border-color: #66cc98;
}
.reading-item .delete-button {
position: absolute;
top: 5px;
right: 5px;
border-radius: 100%;
padding: 0;
width: 20px;
height: 20px;
border: 0;
background-color: transparent;
color: #ccc;
transform: rotateZ(0) scale(1);
transition: transform 0.3s ease, box-shadow 0.5s ease;
}
.reading-item .edit-button,
.reading-item .save-button {
position: absolute;
bottom: 10px;
right: 10px;
padding: 0;
width: 10px;
height: 10px;
border: 0;
background-color: transparent;
color: #ccc;
border-radius: 0;
margin: 0;
}
.reading-item .delete-button:hover {
background-color: #ccc;
color: #fff;
transform: rotateZ(90deg) scale(2);
box-shadow: 1px 0 1px rgba(0, 0, 0, 0.15);
}
<body class="popup-page">
<div class="container">
<header>
<h1 data-localize="appName">Reading List</h1>
<button class="button save-button" id="savepage">+</button>
</header>
<div class="search">
<label for="my-search" data-localize="search">Search</label>
<input type="search" id="my-search" name="search" autocomplete="off">
</div>
<div class="reading-list" id="reading-list">
<div class="reading-item read">
<a value="www.example.com" class="button delete-button">×</a>
<a class="item-link" href="www.example.com" alt="Reading List">
<input class="edit-title" value="Site Title">
<span class="host">example.com</span>
</a>
<img src="/icons/save.svg" class="button save-button"></div>
</div>
</div>
<div class="overlay" id="overlay"></div>
</body>
https://jsfiddle.net/qyca9489/
Can do it using css box-shadow.
.box{display:inline-block; width:100px; height:100px; margin-top:50px; text-align:center; padding-top:2em}
.box.selected{
box-shadow: 0 0 0 99999px rgba(0, 0, 0, .5);
}
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box selected">Box 3</div>
<div class="box">Box 4</div>
Alternate solution using 4 overlay elements
Overlays are positioned based on highlighted element position and dimensions.
The top and bottom overlays are 100% width. The top one just needs it's height set to value of top offset of highlighted element. Bottom one gets it's top set to bottom of the element.
Right and left are same height as highlighted element and reach to each edge of page to fill holes between the top and bottom overlays
var $el = $('.box.selected'),
$oLay = $('.overlay'),
elPos = $el.offset(),// coordinates of element within document
elH = $el.height(),
elW = $el.width();
$oLay.filter('.top').height(elPos.top);
$oLay.filter('.left').css({
top: elPos.top,
height: elH,
width: elPos.left
});
$oLay.filter('.right').css({
top: elPos.top,
height: elH,
left: elPos.left + elW
});
$oLay.filter('.bottom').css({
top: elPos.top + elH
});
.box {
display: inline-block;
width: 100px;
height: 100px;
margin-top: 50px;
text-align: center;
padding-top: 2em
}
.overlay {
position: absolute;
background: rgba(0, 0, 0, .5);
z-index: 100
}
.overlay.top {
top: 0;
left: 0;
width: 100%
}
.overlay.left {
left: 0
}
.overlay.right {
right: 0
}
.overlay.bottom {
width: 100%;
left: 0;
bottom: 0
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box selected">Box 3</div>
<div class="box">Box 4</div>
<div class="overlay top"></div>
<div class="overlay left"></div>
<div class="overlay right"></div>
<div class="overlay bottom"></div>
You could put a second overlay inside <a class="item-link" href="www.example.com" alt="Reading List">. So:
<a class="item-link" href="www.example.com">
<div class="overlay"></div>
…
</a>
And in the CSS:
.item-link {
position: relative
}

How do I get a div to move with window resize without pushing other divs out of the way?

I've spent a long time trying to get this working.
I have a section called "RightExtra" and a div inside it called "RightExtraContent". I'm trying to make it so that these two divs can move freely when the window is resized up to a certain point, without affecting the position of any other divs.
Here is a visual explanation of what I mean:
http://i.imgur.com/A3qBGsj.png
And here is the fiddle: http://jsfiddle.net/c21nzs13/1/
I've tried a bunch of different code combinations and still no success.
* {
padding: 0;
margin: 0;
}
html {
background: #1e1e1e;
/*Back Colors 1*/
}
body {
background-color: #1e1e1e;
/*background:url('https://snap-photos.s3.amazonaws.com/img-thumbs/960w/4657039731.jpg');*/
}
a {
color: #FFFFFF;
text-decoration: none;
}
a:active,
a:hover {
text-decoration: underline;
}
.nofancy a {
text-decoration: none;
}
/*These nofancies don't work*/
.nofancy a:hover {
text-decoration: none;
}
/*These nofancies don't work*/
#heady {
text-align: center;
width: 100%;
height: 75px;
background-color: #1e1e1e;
/*Back Colors 2*/
font-family: Tahoma;
font-size: 16px;
color: #000000;
position: relative;
margin-bottom: 30px;
}
#wrapper {
text-align: center;
width: 1000px;
height: 100%;
margin-left: auto;
margin-right: auto;
/*background-color:#1e1e1e; Back Colors 3*/
font-family: Tahoma;
font-size: 16px;
position: relative;
}
#RightExtra {
background-color: none;
width: 500px;
float: right;
margin-left: auto;
margin-right: auto;
position: relative;
}
#RightExtraContent {
font-family: Tahoma;
font-size: 16px;
height: 800px;
width: 300px;
color: white;
background-color: #343434;
text-align: center;
border-radius: 30px;
position: fixed;
float: right;
}
#followfoot {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 180px;
background-color: none;
text-align: center;
/*display:none;*/
}
#mag {
background-color: #739FE0;
border-color: #739FE0;
border-style: solid;
border-width: 2px;
border-radius: 20px;
line-height: 10px;
text-align: center;
margin-left: 8px;
cursor: pointer;
}
#feety {
text-align: center;
width: 100%;
height: 0px;
//100px background-color:darkslateblue;
/*Back Colors 4*/
font-family: Tahoma;
font-size: 16px;
color: white;
position: fixed;
//Changing this to relative makes followfoot disappear when you scroll long enough.
}
.UpCenter {
/*background-color:#1e1e1e; Back Colors 5*/
padding-top: 30px;
margin-bottom: 50px;
height: 90px;
}
.SignUp {
background-color: #ccc;
border-width: 1px;
border-color: #ccc;
border-radius: 10px;
width: 75px;
padding: 0px 0px;
margin-left: 30px;
text-align: center;
float: right;
}
/* clearfix */
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
.cf:after {
content: " ";
/* 1 */
display: table;
/* 2 */
}
.cf:after {
clear: both;
}
.cf {
* zoom: 1;
}
ul.navbar {
border-style: solid;
border-width: 1px;
border-color: #739FE0;
width: 100px;
/*Widthchanger1*/
border-radius: 4px;
margin-left: 0px;
margin-right: 0px;
font-size: 14px;
height: 33px;
}
ul.navbar li a.ActiveListItem {
color: white;
!important;
background-color: #222 !important;
padding: 7.5px 0px !important;
font-weight: normal !important;
margin-left: 0px;
/*Widthchanger2, got the activeitem centered with list text this way*/
margin-right: 0px;
border-radius: 4px;
height: 18px;
width: 100px;
/*kinda messes with width of text*/
margin-bottom: 1px;
}
ul.navbar li {
position: relative;
width: 100px;
/*Changes width of actual list*/
}
ul.navbar li a {
display: block;
color: white;
padding: 10px 5px;
text-decoration: none;
transition: all .1s ease-in;
}
ul.navbar li a:hover,
ul.navbar li:hover > a {
/*background:black; */
background: #739FE0;
color: #FFFFFF;
/*font-weight:600;*/
/*border-bottom-color:#FFFFFF;
border-bottom-style:solid;*/
/*border-color:#FFFFFF;
border-style:solid;
border-width:1px; */
}
ul.navbar li ul {
margin-top: 0px;
/*Controls space from listdropdown to listchooser*/
position: absolute;
background: #222;
font-size: 14px;
/* min-width: 200px; */
display: none;
z-index: 99;
box-shadow: inset 0 0px 3px rgba(0, 0, 0, .6), 0 5px 10px rgba(0, 0, 0, .6);
}
ol,
ul {
list-style: outside none none;
}
.hidden {
display: none;
}
/*Lister*/
form {} .lister input {
width: 235px;
/*width of todo input box*/
height: 33px;
padding-left: 10px;
padding-right: 10px;
border-width: 1px;
border-style: solid;
border-color: #739FE0;
float: left;
margin-bottom: 20px;
font-size: 14px;
font-family: "Tahoma";
background-color: #222;
color: white;
}
.lister input:focus {
outline: none;
border-color: #739FE0;
/*ccc*/
box-shadow: 0px 0px 7px 0px #739FE0;
}
.lister ul {
/*list-style: square inside;*/
padding: 10px 0px 55px 0px;
/* padding for outside area of list*/
/* This is what's visible when not in use Used to be 10*/
/*height:50px;*/
/*background: #0f705d; DarkerOutsideColor*/
background: none;
/*width: 100%;*/
font-family: "Tahoma";
}
.active {
text-align: center;
}
.inactive {
display: none;
}
.lister li {
font-size: 14px;
/*font size of list items*/
/*font-weight: 600;*/
color: #181818;
/*Font Color d5faf3*/
display: inline-block;
/*This makes the items side-by-side and not columns*/
padding: 9px;
margin-bottom: 5px;
/*SEPARATE*/
/* float:left; Interferes with text-align of Active*/
}
.lister li:nth-child(odd) {
background: #343434;
/*LighterInside Color,Odd*/
border-color: #ccc;
border-width: 1px;
border-radius: 5px;
border-style: solid;
box-shadow: 0px 0px 10px 0px #000000;
color: #ccc;
/*opacity:0.6;
filter:alpha(opacity=60);*/
}
.lister li:nth-child(even) {
background: #343434;
/*LighterInside Color,Even*/
border-color: #ccc;
border-width: 1px;
border-radius: 5px;
border-style: solid;
box-shadow: 0px 0px 10px 0px #000000;
color: #ccc;
}
.lister li > a {
/*float: right;*/
text-decoration: none;
color: white;
font-weight: bold;
/*transition: all .2s ease-in-out;*/
/*position:relative;*/
margin-top: 2px;
display: inline-block;
}
.lister li > a:hover {
/*font-size: 105%;*/
/*color: #c0392b;*/
color: #000000;
}
.lister li > span {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 379px;
}
/*Clearable*/
.clearable {
/*background: #fff; */
/*background:url(../images/splusgreen.png); */
background-repeat: no-repeat;
background-size: 10px 10px;
background-position: right 5px center;
/* -15*/
transition: background 0.4s;
}
.clearable.x {
/*background-position: right 5px center;*/
}
.clearable.onX {
cursor: pointer;
}
<section id="heady">
<div style="width:1000px;margin-left:auto;margin-right:auto;">
<div style="text-align: left;padding:25px 0px;display:inline-block;float:left;font-size:18px;"><b>Calories</b>
</div>
<div style="text-align: right;padding:25px 00px;display:inline-block;float:right;">
<!--Home | --> Sign In | Sign Up
</div>
</div>
</section>
<section id="RightExtra">
<div id="RightExtraContent">Yes hello....!</div>
</section>
<section id="wrapper">
<br>
<br>
<div class="UpCenter">
<div style="vertical-align:top;display:inline-block;">
<ul class="navbar cf">
<li> Category
<ul></ul>
</li>
</ul>
</div>
<div class="lister" style="display:inline-block;vertical-align:top;padding:0px 0px 0px 10px;">
<form action="">
<input type="text" class="clearable" placeholder="Add your meals here..." autocomplete="off">
</form>
</div>
<div id="mag" style="display:inline-block;vertical-align:top;">
<img src="images/magCircy.png" width="33px" height="33px" onClick="changeHeight(this,event);"></img>
</div>
</div>
</div>
</section>
<section id="followfoot"></section>
In order to achieve this, I increased the width of the wrapper and moved the new div into it.

Fix element vertically, move when scrolled horizontally

I'm stuck on this one. Anyone up for a css puzzle?
I need the element displaying the scrolling text to remain fixed while scrolling down the page but then to be able to move if scrolled horizontally.
I made a jsfiddle to demo the issue. You can find it here: http://jsfiddle.net/6tPpE/
HTML:
<body>
<section id="front_page">
<div id = "ticker_placer">
<div id="ticker_holder">
<div id="ticker_ribbon">
<ul id ="ticker">
<li>Scrolling on Jin & Juice</li>
</ul>
</div>
</div>
</div>
</section>
</body>
CSS:
body {
width: 700px;
height: 700px;
background:yellow;
}
#ticker_placer {
position: absolute;
left: 0px;
width: 68%;
min-width: 871px;
z-index: 1;
}
#ticker_holder {
position: fixed;
width: 68%;
min-width: 871px;
}
#ticker_ribbon {
position:relative;
padding: 0 10px;
margin: 0 0 0 -10px;
width: 400px;
height: 35px;
background: rgba(0,0,0,.25);
border-top-left-radius: 5px;
border-top-right-radius: 5px;
box-shadow:
inset 0 1px rgba(255,255,255,.3),
inset 0 10px rgba(255,255,255,.2),
inset 0 10px 20px rgba(255,255,255,.25),
inset 0 -15px 30px rgba(0,0,0,.3),
inset 0 -1px 6px rgba(0,0,0,.3);
}
#ticker_ribbon:before, #ticker_ribbon:after {
content:" ";
border-top:10px solid rgba(0,0,0,.6);
position:absolute;
bottom:-10px;
}
#ticker_ribbon:before {
border-left:10px solid transparent;
left:0;
}
#ticker_ribbon:after {
border-right:10px solid transparent;
right:0;
}
.tickercontainer {
position: absolute;
left: 0;
width: 400px;
}
.mask {
overflow: hidden;
}
ul.newsticker { /* that's your list */
position: relative;
left: 1000px;
font: 10px;
font-family: "KeplerStd-Regular";
src: url('Fonts/KeplerStd-Regular.ttf') format('truetype');
list-style-type: none;
color: white;
margin: 0;
padding: 0;
}
ul.newsticker li {
float: left; /* important: display inline gives incorrect results when you check for elem's width */
margin: 5px 0;
padding: 0;
}
section#front_page {
position: relative;
margin: 0 2.5%;
width: 400px;
height: 400px;
background: green;
box-shadow: 0 0 10px -2px #AAAAAA;
}
$(window).scroll(function(){
$('#ticker_holder').css('left',-$(window).scrollLeft()+26);
});
This sets the positon of the div whenever it scrolls left..
Using scrollLeft() I get the amount of scrolling and this 26px is for positioning it properly..so setting the left property..
Working Fiddle:http://jsfiddle.net/6tPpE/1/
You need to make the body the same width as the fixed element:
body {
width: 400px;
}

convert css code from :hover to click

i have a problem :
there is in code , popup opens and close when the mouse hovers over the image, I want it to open and close when i press on the image .
photo on this code:
<a class="textlink" href="#" style="padding:10px 0;">
<img src="alert/images.gif" style="width: 21px;" />
<span id="mes">$count</span>
</a>
the full code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<style type="text/css">
a {
text-decoration: none;
color: #838383;
}
a:hover {
color: black;
}
#menu {
position: relative;
margin-left: auto;
top: -34px;
}
#menu ul {
list-style-type: none;
}
#menu li {
float: left;
position: relative;
text-align: center;
}
#menu ul.sub-menu {
position: absolute;
left: -10px;
z-index: 90;
display: none;
}
#menu ul.sub-menu li {
text-align: right;
}
#menu li:hover ul.sub-menu {
display: block;
}
.egg {
padding: 10px;
margin: 5px 5px 5px 5px;
position: relative;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
background-color: #fff;
border-radius: 3px 3px 3px 3px;
border: 1px solid rgba(100, 100, 100, 0.4);
}
.egg_Body {
border-top: 1px solid #D1D8E7;
color: #808080;
}
.egg_Message {
font-size: 13px !important;
font-weight: normal;
overflow: hidden;
}
h3 {
font-size: 13px;
color: #333;
margin: 0;
padding: 0;
}
.comment_ui {
border-bottom: 1px solid #e5eaf1;
clear: left;
float: none;
overflow: hidden;
padding: 6px 4px 3px 6px;
width: 331px;
cursor: pointer;
white-space: pre-line;
}
.comment_ui:hover {
background-color: #F7F7F7;
}
.comment_actual_text img {
margin: 0px 0px 0px 7px;
}
.dddd {
background-color: #f2f2f2;
border-bottom: 1px solid #e5eaf1;
clear: left;
float: none;
overflow: hidden;
margin-bottom: 2px;
padding: 6px 4px 3px 6px;
width: 331px;
}
.comment_text {
border-radius: 2px 2px 2px 2px;
padding: 2px 0 4px;
color: #333333;
}
.comment_actual_text {
display: inline;
padding-left: .4em;
}
ol {
list-style: none;
margin: 0 auto;
width: 500px;
margin-top: 20px;
}
#mes {
padding: 0px 3px;
border-radius: 3px 3px 3px 3px;
background-color: rgb(240, 61, 37);
background-color: #FF00CC;
font-size: 9px;
font-weight: bold;
color: #fff;
position: absolute;
top: 5px;
left: 73px;
}
.toppointer {
background-image: url(alert/top.png);
background-position: -82px 0;
background-repeat: no-repeat;
height: 11px;
position: absolute;
top: -11px;
width: 20px;
right: 276px;
}
.clean {
display: none
}
.textlink {
display: block;
width: 140px;
}
</style>
<span id="menu">
<ul>
<li>
<a class="textlink" href="#" style="padding:10px 0;">
<img src="alert/images.png" style="width: 21px;" />
<span id="mes">$count</span>
</a>
<ul class="sub-menu">
<li class="egg">
<div class="toppointer">
<img src="alert/top.png" />
</div>
<div id="view_comments"></div>
$all
<if condition="$count_all > 0 ">
<div class="bbbbbbb" id="view">
<div style="background-color: #F7F7F7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; position: relative; z-index: 100; padding:8px; cursor:pointer;">
view all
</div>
</div>
</if>
</li>
</ul>
</li>
</ul>
</span>
Thank you very much !
Instead of the :hover pseudo-class, use the :active pseudo-class.
So the CSS block would look like this:
a:active {
color: black;
}
For more info, take a look at this: https://developer.mozilla.org/en-US/docs/Web/CSS/:active
Toggle with only CSS is a little bit tricky, but here is one way of doing it:
Demo: http://jsfiddle.net/DerekL/R5Bm5/
<input id="control" type="checkbox">
<label for="control"><span id="toggle">Toggle</span></label>
<div class="more">Here's more</div>
.more{
height: 0px;
overflow: hidden;
}
#control:checked ~ .more{
/*Do whatever you want here*/
height: 20px;
}
#control{
display: none;
}
#toggle{
color: blue;
text-decoration: underline;
cursor: pointer;
}
Of course, you can always toggle with JavaScript:
$("#toggle").click(function(){
$(".more").toggle();
});
A better demo according to your description: http://jsfiddle.net/DerekL/R5Bm5/2/

Issue with div floating on top of carousel

I'm using jCarousel and there's a weird bug on my page and I can't figure it out! Essentially, I'm trying to overlay a <div> on top of my carousel.
When I place the <div> on top, this weird gap pops up on top of the carousel! I don't know where it's coming from. Is it in the JavaScript?
The black box, I can format later. Just need to know why the white space is appearing.
JsFiddle from the bug
HTML
<div class="carousel-wrapper">
<div class="jcarousel-wrapper">
<div class="jcarousel">
<ul>
<li>
<img src="http://placekitten.com/850/500" width="850" height="500" alt="">
</li>
<li>
<img src="http://placekitten.com/850/500" width="850" height="500" alt="">
</li>
<li>
<img src="http://placekitten.com/850/500" width="850" height="500" alt="">
</li>
</ul>
</div>
‹
›
<p class="jcarousel-pagination"></p>
</div>
</div>
CSS
#login-carousel-wrapper {
width: 850px;
height: 500px;
margin: 0px auto;
}
#login-carousel-area {
background-color: #000;
z-index: 999;
width: 200px;
height: 200px;
position: relative;
top: 200px;
left: 100px;
}
#body-wrapper {
width: 970px;
height: 100%;
margin: 0px auto;
text-align: top;
}
.carousel-wrapper {
max-width: 850px;
/*padding: 0 20px 40px 20px;*/
margin: auto;
}
.jcarousel-wrapper {
margin: 20px auto;
position: relative;
border: 10px solid #fff;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 0 2px #999;
-moz-box-shadow: 0 0 2px #999;
box-shadow: 0 0 2px #999;
}
.jcarousel-wrapper .photo-credits {
position: absolute;
right: 15px;
bottom: 0;
font-size: 13px;
color: #fff;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.85);
opacity: .66;
}
.jcarousel-wrapper .photo-credits a {
color: #fff;
}
/** Carousel **/
.jcarousel {
position: relative;
overflow: hidden;
width: 850px;
height: 500px;
}
.jcarousel ul {
width: 20000em;
position: relative;
list-style: none;
margin: 0;
padding: 0;
}
.jcarousel li {
float: left;
}
/** Carousel Controls **/
.jcarousel-control-prev, .jcarousel-control-next {
position: absolute;
top: 200px;
width: 30px;
height: 30px;
text-align: center;
background: #4E443C;
color: #fff;
text-decoration: none;
text-shadow: 0 0 1px #000;
font: 24px/27px Arial, sans-serif;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
-webkit-box-shadow: 0 0 2px #999;
-moz-box-shadow: 0 0 2px #999;
box-shadow: 0 0 2px #999;
}
.jcarousel-control-prev {
left: -50px;
}
.jcarousel-control-next {
right: -50px;
}
.jcarousel-control-prev:hover span, .jcarousel-control-next:hover span {
display: block;
}
.jcarousel-control-prev.inactive, .jcarousel-control-next.inactive {
opacity: .5;
cursor: default;
}
/** Carousel Pagination **/
.jcarousel-pagination {
position: absolute;
bottom: 0;
left: 15px;
}
.jcarousel-pagination a {
text-decoration: none;
display: inline-block;
font-size: 11px;
line-height: 14px;
min-width: 14px;
background: #fff;
color: #4E443C;
border-radius: 14px;
padding: 3px;
text-align: center;
margin-right: 2px;
opacity: .75;
}
.jcarousel-pagination a.active {
background: #4E443C;
color: #fff;
opacity: 1;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75);
}
Live Demo
If you are talking about the 20px white line in the top, that comes from .jcarousel-wrapper's margin: 20px auto;.
Just change 20px to 0px or add a new line overwriting margin-top if you want to keep the bottom margin:
.jcarousel-wrapper {
margin: 20px auto;
margin-top: 0px;
}

Categories

Resources