Stuck with responsive and timeline design with masonry - css

I am very new to tumblr and jQuery Masonry, I have create a test blog.
I have a timeline design, by which posts are aligned in two sides and also I used Masonry to remove the space between the posts.
And I have added responsive behavior to this.
Post and Masonry is working properly with responsive on different window size when the page loads but when i resize the window, its design goes to haywire.
I am not able to identify is it my code's mistake or Masonry's :(
Any help will be really helpful.
It is not working with only (min-width: 768px), (min-width: 1024px) and (min-width: 1824px)
Here is my code:
JS
$(document).ready(function() {
if ($(window).width() <= 679) {
$('#posts_container').masonry('destroy');
}
if ($(window).width() > 680) {
$('#posts_container').masonry({itemSelector: '.shadow', });
}
Arrow_Points();
});
function Arrow_Points() {
//alert("function call");
var s = $('#posts_container').find('.shadow');
$.each(s, function(i, obj) {
var posLeft = $(obj).css("left");
$(obj).addClass('borderclass');
if (posLeft == "0px") {
html = "<span class='rightCorner'></span>";
html += "<div class='rightpostcorner'></div>";
$(obj).prepend(html);
$(this).addClass('margin_hack_left_post');
}
else
{
html = "<span class='leftCorner'></span>";
html += "<div class='leftpostcorner'></div>";
$(obj).prepend(html);
$(this).addClass('margin_hack_right_post');
}
});
}
Media
#media only screen and (max-width: 480px) {
.wrapper {width: 100%;}
.rightCorner, .leftCorner{ display: none; }
.shadow {width: 90%; margin: 40px 5% 10px 5%; }
}
#media only screen and (max-width: 680px) and (min-width: 480px){
.wrapper {width: 100%;}
.rightCorner, .leftCorner{ display: none; }
}
#media only screen and (max-width: 768px) and (min-width: 680px){
.wrapper {width: 100%;}
.rightCorner, .leftCorner{ display: none; }
.shadow {width: 90%; margin: 40px 5% 10px 5%; }
}
#media only screen and (min-width: 768px) and (max-width: 1024px) {
.leftCorner { margin-left:-9%;}
.shadow { width: 45.5%; margin-top: 40px; }
.margin_hack_left_post { margin-left:1.5%%; }
.margin_hack_right_post { margin-left:7.5%; }
}
#media only screen and (min-width: 1025px) and (max-width: 1824px) {
.wrapper {width: 100%; }
.leftCorner {margin-left: -5.5%; }
.shadow { width: 43.7%; margin-top: 40px; }
.margin_hack_left_post { margin-left:4%; }
.margin_hack_right_post { margin-left:8%; }
}
/* LARGE SCREENS */
#media only screen and (min-width: 1824px) {
.wrapper {width: 1200px; margin: 0 auto;}
.shadow { width: 43.7%; margin-top: 40px; }
.margin_hack_left_post { margin-left:4%; }
.margin_hack_right_post { margin-left:8%; }
}
My CSS:
.shadow
{
float: left;
background-color: #ffffff;
min-height: 50px;
text-align: justify;
word-wrap:break-word;
}
.timeline_container
{
width: 16px;
text-align: center;
margin: 0 auto;
cursor:pointer;
display: block;
}
.timeline
{
margin: 0 auto;
background-color: red;
display: block;
float: left;
height: 100%;
left: 49.75%;
position: absolute;
width: 1px;
z-index: -1;
}
.timeline:hover{cursor: pointer;margin: 0 auto;}
.timeline div.plus{width: 14px;height: 14px;position: relative;left: -6px;}
.rightCorner
{
background-image: url("xyz.png");
height: 30px;
margin-left: 99.5%;
margin-top: 8px;
padding: 0;
vertical-align: top;
width: 30px;
z-index: 2;
position: absolute;
}
.leftCorner
{
background-image: url("abc.png");
height: 30px;
width: 30px;
margin-top: 8px;
position: absolute;
z-index:2;
}
.content
{
margin-left: auto;
margin-right: auto;
max-width: none;
min-width: 86%;
position: relative;
z-index: 2;
}
And my tumblr HTML is
{block:Posts}
<article class="shadow">
{block:Date}
<div class="post_info">
<section class="post-controls">
<ul style="padding-left: 0px; float: left; width:80%">
<li style="width: 30%; margin-left: 0px; padding-left: 0px; margin-top: 7px;">
<i class="icon-clock"></i> {DayOfMonthWithZero} {ShortMonth} {ShortYear}
</li>
{block:NoteCount}<li style="width: 30%; margin-left: 0px; padding-left: 0px; margin-top: 7px;">
<i class="icon-heart"></i> {NoteCount}</li>{/block:NoteCount}
</ul>
<ul style="float:right;">
<li class="like_link">{ReblogButton size="20"}</li>
<li class="reblog_link">{LikeButton size="20"}</li>
</ul>
</section>
</div>
{/block:Date}
<div class="post_padding">
{block:Audio}
<div class="audio" id="{PostID}">
<div class="album_art">{block:AlbumArt}<img class="scale-with-grid" src="{AlbumArtURL}" />{/block:AlbumArt}</div>
<div class="audio_player_container">
{block:AudioEmbed}{AudioEmbed}{/block:AudioEmbed}
{block:AudioPlayer}{AudioPlayerWhite}{/block:AudioPlayer}
</div>
<div class="caption">
<ul class="audio_details">
{block:TrackName}<li><span class="audio_bold">Song Title:</span> {TrackName}</li>{/block:TrackName}
{block:Artist}<li><span class="audio_bold">Artist:</span> {Artist}</li>{/block:Artist}
{block:Album}<li><span class="audio_bold">Album:</span> {Album}</li>{/block:Album}
<li><span class="audio_bold">Plays:</span> {PlayCount}</li>
</ul>
{block:Caption}{caption}{/block:Caption}
</div>
</div>
{/block:Audio}
{block:Chat}
{block:Title}<div class="chat_title"><h2>{Title}</h2></div>{/block:Title}
{block:Lines}
<div class="lines"><div class="line {Alt}">{block:Label}<strong>{Label}</strong>{/block:Label} {Line}</div></div>
{/block:Lines}
{/block:Chat}
{block:Link}
<div class="link_title"><a href="{URL}" {Target}>{Name} →</a></div>
<div class="caption">{block:Description}{Description}{/block:Description}</div>
{/block:Link}
{block:Photo}
<div class="photo_post">
<a href="{Permalink}" rel="prettyPhoto">
<img class="scale-with-grid" src="{PhotoURL-HighRes}"/>
</a>
</div>
{block:Caption}<div class="caption">{Caption}</div>{/block:Caption}
{/block:Photo}
{block:Photoset}
<div class="photo-slideshow" data-layout="{PhotosetLayout}">
{block:Photos}
<div class="photo-data">
<div class="photo">
<a href="{Permalink}" rel="prettyPhoto[set]">
<img alt="{PhotoAlt}" src="{PhotoURL-500}" data-highres="{PhotoURL-HighRes}" class="{block:Exif}exif-yes {/block:Exif}{block:Caption}caption-yes{/block:Caption}" {block:Exif}data-camera="{block:Camera}{Camera}{/block:Camera}" data-iso="{block:ISO}{ISO}{/block:ISO}" data-aperture="{block:Aperture}{Aperture}{/block:Aperture}" data-exposure="{block:Exposure}{Exposure}{/block:Exposure}" data-focal="{block:FocalLength}{FocalLength}{/block:FocalLength}"{/block:Exif} {block:Caption}data-caption="{Caption}"{/block:Caption}>
</a>
</div>
<div class="icons">
<a rel="prettyPhoto" class="view" rel="post-{PostID}" href="{PhotoURL-HighRes}"><span class="zoom">Zoom</span></a>
<span class="info">Info</span>
</div>
</div>
{/block:Photos}
</div><!-- close SLIDESHOW -->
<div class="caption">{block:Caption}{Caption}{/block:Caption}</div>
{/block:Photoset}
{block:Quote}
<div class="quote_title"><h2>"{Quote}"</h2></div>
<div class="caption"><p>{block:Source}- {Source}{/block:Source}</p></div>
{/block:Quote}
{block:Text}
{block:Title}<div class="post_title"><h2>{Title}</h2></div>{/block:Title}
<div class="caption">{Body}</div>
{/block:Text}
{block:Video}
<div class="video_post">
<figure><div class="embed">{Video-500}</div></figure>
{block:Caption}<div class="caption">{Caption}</div>{/block:Caption}
</div>
{/block:Video}
</div>
</article>
{/block:Posts}

The Javascript will generate hard-pixels for the left-margin, depending on the width of browser window. Change the hard pixels to 50%.
jQuery:
$(this).css("left", "50%");

Related

CSS for image layout issues

I'm learning responsive CSS, so this is all fairly new to me. However, why aren't the images on the 2nd row hugging the top images?
Ideally I just want 4 images per row, but if on a smaller screen or phone etc. it will dynamically reduce the image size and reduce the number of images per row. Cannot seem to get this working? Any help is appreciated! All CSS relative for the images is on that one static page.
div.gallery {
border: 1px solid #ccc;
}
div.gallery:hover {
border: 1px solid #777;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 10px;
text-align: center;
}
* {
box-sizing: border-box;
}
.responsive {
padding: 0 6px;
float: right;
width: 24.99999%;
}
#media only screen and (max-width: 700px) {
.responsive {
width: 49.99999%;
margin: 6px 0;
}
}
#media only screen and (max-width: 500px) {
.responsive {
width: 100%;
}
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
<div class="responsive">
<div class="gallery">
<a target="_blank" href="https://memorybox.pt">
<img src="images/memory-box.png" alt="Algarve Wedding Photography" width="600" height="400">
</a>
<div class="desc">Algarve Wedding Planners</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="https://algarvedjhire.com/">
<img src="images/algarve_dj_hire.jpg" alt="Algarve Wedding Photography" width="600" height="400">
</a>
<div class="desc">Algarve DJ & Music</div>
</div>
Use height and instead of float right use float left in your .responsive class. See example below. I use height 290px you can use based on your need.
.responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
height: 290px;
}
Also you can use margin-bottom in your responsive break point so that it's look good. See example below.
#media only screen and (max-width: 700px) {
.responsive {
width: 49.99999%;
margin: 6px 0 30px 0;
}
}

How to horizontally align my elements for tablet layout?

I want to have three different layouts of my web page for different browser widths (i.e. desktop, tablet, phone).
In the tablet layout (between 768px and 991px of the browser) I should have three elements, two in the first row (thus each of them taking 6/12 of the browser width) and the a third in the second row (taking 12/12 of the browser width).
This is what I want:
What I want - IMAGE
But I have a problem with this layout:
I am not able to set the third element borders aligned with the left and right borders of first and second element, as you see.
This is what I have done:
What I have - IMAGE
Can you help me?
Note: I want the element '3' wide as '1'+'2' width only for tablet layouts! For other layouts I want what I already did, i.e same width for every element (1,2 or 3).
This is the html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Our Menu</title>
<link rel ="stylesheet" href="css/style.css">
</head>
<body>
<h1>Our Menu</h1>
<div class="row">
<div class="col-lg-4 col-md-6 col-sd-12 anchor">
<p class="content"> In girum imus nocte et consimur igni.</p>
<p class="my-title" id="p1"> Chicken</p>
</div>
<div class="col-lg-4 col-md-6 col-sd-12 anchor">
<p class="content"> In girum imus nocte et consimur igni.</p>
<p class="my-title" id="p2"> Beef</p>
</div>
<div class="col-lg-4 col-md-12 col-sd-12 anchor">
<p class="content"> In girum imus nocte et consimur igni.</p>
<p class="my-title" id="p3"> Sushi</p>
</div>
</div>
</body>
</html>
This is the css:
/* width and height will include border and padding */
* {
box-sizing: border-box;
}
h1 {
margin-bottom: 15px;
text-align: center;
}
/*Set an anchor for the container of p elements*/
div.anchor{
position: relative;
}
#p1{
background-color: yellow;
}
#p2{
background-color: #ff0000;
}
#p3{
background-color: #ffaabb;
}
/*.col-md-12 .content{
margin-right: 2.5%;
margin-left: 2.5%;
*/
p.content{
border: 1px solid black;
background-color: #a3d3d3;
/*width: 90%; /*Specifies a percentage width. The percentage is calculated with respect to the width of the generated box's containing block.*/
height: 150px;
margin-right: 5%;
margin-left: 5%;
font-family: Helvetica;
color: white;
padding: 20px;
}
p.my-title{
position: absolute;
top: 0px;
right: 0px;
width: 80px;
height: 20px;
margin: 0px;
border: 1px solid black;
text-align: center;
margin-right: 5%;/*inherit; 22.525px; inherit*/
margin-top: 16px;
/*margin-right: auto;
margin-left: auto;
font-family: Helvetica;*/
color: black;
}
/* Simple Responsive Framework. */
.row {
width: 100%;
}
/********** desktop devices only **********/
#media (min-width: 992px) {
.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4 {
float: left;
}
.col-lg-1 {
width: 8.33%;
}
.col-lg-2 {
width: 16.66%;
}
.col-lg-3 {
width: 25%;
}
.col-lg-4 {
width: 33.33%;
}
}
/********** Tablet devices only **********/
#media (min-width: 768px) and (max-width: 991px) {
.col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-12 {
float: left;
}
.col-md-4 {
width: 33.33%;
}
.col-md-5 {
width: 41.66%;
}
.col-md-6 {
width: 50%;
}
.col-md-7 {
width: 58.33%;
}
.col-md-8 {
width: 66.66%;
}
.col-md-12 {
width: 100%;
/*margin-right: -5.5%;
margin-left: -2.8%;*/
}
}
/********** mobile devices only **********/
/* the floating is only defined inside the media queries.
The elements will behave just like regular block level elements,
and they will automatically stack one on top of the other.
Anyway, it's better to explicit define the media query also for
mobile phones. */
#media (max-width: 767px) {
.col-sd-9, .col-sd-10, .col-sd-11, .col-sd-12 {
float: left;
}
.col-sd-9 {
width: 74.99%;
}
.col-sd-10 {
width: 83.33%;
}
.col-sd-11 {
width: 91.66%;
}
.col-sd-12 {
width: 100%;
}
}
Thank you!
check this fiddle
div.anchor{
position: relative;
padding: 0 15px;
}
p.content{
border: 1px solid black;
background-color: #a3d3d3;
/*width: 90%; /*Specifies a percentage width. The percentage is calculated with respect to the width of the generated box's containing block.*/
height: 150px;
/* margin-right: 5%;
margin-left: 5%; */
font-family: Helvetica;
color: white;
padding: 20px;
}
p.my-title{
position: absolute;
top: 16px;
right: 15px;
width: 80px;
height: 20px;
margin: 0px;
border: 1px solid black;
text-align: center;
/* margin-right: 5%;inherit; 22.525px; inherit
margin-top: 16px; */
/*margin-right: auto;
margin-left: auto;
font-family: Helvetica;*/
color: black;
}
EDITS:
removed margin left and right on p.content and p.my-title, added padding on div.anchor and top and right position on p.my-title

How to modify responsive timeline?

http://codepen.io/kjohnson/pen/azBvaE
My friend and I are thinking of using that timeline in our website. But the problem is we've 5 sections that needs to be added to timeline, whereas the original timeline have only 3 sections.
I've tried to add two more sections to that code, but it's losing its shape and responsiveness.
Is it possible to extend that timeline and maintain its responsiveness?
HTML
<!-- STEPS -->
<section id="Steps" class="steps-section">
<h2 class="steps-header">
Responsive Semantic Timeline
</h2>
<div class="steps-timeline">
<div class="steps-one">
<img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
<h3 class="steps-name">
Semantic
</h3>
<p class="steps-description">
The timeline is created using negative margins and a top border.
</p>
</div>
<div class="steps-two">
<img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
<h3 class="steps-name">
Relative
</h3>
<p class="steps-description">
All elements are positioned realtive to the parent. No absolute positioning.
</p>
</div>
<div class="steps-three">
<img class="steps-img" src="http://placehold.it/50/3498DB/FFFFFF" alt="" />
<h3 class="steps-name">
Contained
</h3>
<p class="steps-description">
The timeline does not extend past the first and last elements.
</p>
</div>
</div><!-- /.steps-timeline -->
CSS
$outline-width: 0;
$break-point: 500px;
#import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
font-family: lato;
}
$gray-base: #999999;
$brand-primary: #3498DB; //Zen Blue
.section-header {
color: $brand-primary;
font-weight: 400;
font-size: 1.4em;
}
.steps-header {
#extend .section-header;
margin-bottom: 20px;
text-align: center;
}
.steps-timeline {
outline: 1px dashed rgba(red, $outline-width);
#media screen and (max-width: $break-point) {
border-left: 2px solid $brand-primary;
margin-left: 25px;
}
#media screen and (min-width: $break-point) {
border-top: 2px solid $brand-primary;
padding-top: 20px;
margin-top: 40px;
margin-left: 16.65%;
margin-right: 16.65%;
}
&:after {
content: "";
display: table;
clear: both;
}
}
.steps-one,
.steps-two,
.steps-three {
outline: 1px dashed rgba(green, $outline-width);
#media screen and (max-width: $break-point) {
margin-left: -25px;
}
#media screen and (min-width: $break-point) {
float: left;
width: 33%;
margin-top: -50px;
}
}
.steps-one,
.steps-two {
#media screen and (max-width: $break-point) {
padding-bottom: 40px;
}
}
.steps-one {
#media screen and (min-width: $break-point) {
margin-left: -16.65%;
margin-right: 16.65%;
}
}
.steps-two {
}
.steps-three {
#media screen and (max-width: $break-point) {
margin-bottom: -100%;
}
#media screen and (min-width: $break-point) {
margin-left: 16.65%;
margin-right: -16.65%;
}
}
.steps-img {
display: block;
margin: auto;
width: 50px;
height: 50px;
border-radius: 50%;
#media screen and (max-width: $break-point) {
float: left;
margin-right: 20px;
}
}
.steps-name,
.steps-description {
margin: 0;
}
.steps-name {
#extend .section-header;
#media screen and (min-width: $break-point) {
text-align: center;
}
}
.steps-description {
overflow: hidden;
#media screen and (min-width: $break-point) {
text-align: center;
}
}
If you a novice I'd recommend you LEARN first. Copy templates/snippets is good to save your time when you know what you are doing.
I found a perfect tutorial for you here
Just to emphasize that's my opinion, I hope it helps in a certain way..
EDIT: If still want to develop in that way here's a codepen snippet with a fully responsive horizontal timeline. Just have to put more <li> inside the <ul>

Responsive CSS dropdown menu issue

My dropdown CSS menu works fine when I open it in mobile view, but stays there when I resize the window in my browser. When I try to get rid of it in my CSS media query, the dropdown doesn't work at all..
function showmenu(){
var menu = document.getElementById('mobile-menu'), maxH="148px";
if (menu.style.height == maxH){
menu.style.height = "0px";
}else{
menu.style.height = maxH;
}
}
#media(max-width: 1024px){
.col-tab1{
width: 8.33333333333%;
float: left;
}
.col-tab2{
width: 16.6666666667%;
float: left;
}
.col-tab3{
width: 25%;
float: left;
}
.col-tab4{
width: 33.3333333333%;
float: left;
}
.col-tab5{
width: 41.6666666667%;
float: left;
}
.col-tab6{
width: 50%;
float: left;
}
.col-tab7{
width: 58.3333333333%;
float: left;
}
.col-tab8{
width: 66.6666666667%;
float: left;
}
.col-tab9{
width: 75%;
float: left;
}
.col-tab10{
width: 83.3333333333%;
float: left;
}
.col-tab11{
width: 91.6666666667%;
float: left;
}
.col-tab12{
width: 100%;
float: left;
}
.mobile{
display: none;
}
.desktop{
display: none;
}
.tablet{
display: block;
}
#nav-toggle{
width:50px;
float:right;
color:white;
margin:25px;
display:block;
}
nav ul{
list-style-type: none;
margin:auto;
width:500px;
height:100%;
display:none;
}
#mobile-menu{
display:none;
}
}
<body>
<nav>
<span onclick="showmenu('mobile-menu')"></span>
<div id="nav-logo">
<div id="bar1"></div>
<div id="bar2"></div>
<div id="bar3"></div>
<div id="bar4"></div>
<div id="bar5"></div>
<div id="bar6"></div>
<div id="bar7"></div>
</div>
<ul>
<li><p>ABOUT</p></li>
<li><p>WORK</p></li>
<li><p>SERVICES</p></li>
<li><p>CONTACT</p></li>
</ul>
</nav>
<div id="mobile-menu">
<ul>
<li><p>ABOUT</p></li>
<li><p>WORK</p></li>
<li><p>SERVICES</p></li>
<li><p>CONTACT</p></li>
</ul>
</div>
</body>

Why can I not resize this image to its original size

I have an image that will not allow me to resize it.
Here is the image on the responsinator site [a link] (http://www.responsinator.com/?url=http%3A%2F%2Fsandbox.kevinw.me%2Fwilliams%2Fshare.html)
I need it to match the image on here [a link] (http://www.responsinator.com/?url=sandbox.kevinw.me%2Fshare%2Fshare.html)
Here is the html There is a video linked as you can see.
<div id="iphone" class="image">
<!-- Start VideoLightBox.com BODY section -->
<div class="videogallery">
<a class="disabled" href="vdbplayer364e.swf?volume=100&url=video/instagram.mp4" title="Instagram"><img id="iphone" src="img/instagramiphonephone.jpg" class="image" /><span><a class="voverlay" href="vdbplayer.swf?volume=100&url=video/instagram.mp4" title="Instagram"><img id="play_button1" src="img/instagramplaybutton.png" class="image"></a></span></a>
<span class="videolb"><a class="videolb" href="http://videolightbox.com/">Video in Popup</a> by VideoLightBox.com v2.8m</span>
</div>
<script src="js/jquery.tools.min.js" type="text/javascript"></script>
<script src="js/videolightbox.js" type="text/javascript"></script>
<!-- End VideoLightBox.com BODY section -->
</div>
Here is my code
#iphone {
width: 256px;
margin-top: 111px;
margin-left: auto;
clear: none;
margin-right: auto;
float: none;
padding-top: 13.2%;
padding-left: 2.8%;
padding-right: 2.8%;
padding-bottom: 0%;
}
Use below CSS, I think this is use full for your image resize issue:
CSS
#media only screen and (max-width: 768px)
#iphone1 { /******share.css Line:1568***********/
max-width: 256px;
margin-top: 111px;
/* margin-left: -14% !important; */
clear: none;
margin-left: auto;
margin-right: auto;
float: none;
/* padding-top: 34.2%; */
/* padding-left: 2.8%; */
/* padding-right: 2.8%; */
/* padding-bottom: 0%; */
}
#media only screen and (max-width: 360px)
#iphone { /******share.css Line:2316***********/
height: 68%;
padding-top: 48.2%;
/* padding-left: 4.4%; */
/* padding-right: 9.4%; */
padding-bottom: 7.4%;
}

Resources