I have a list with 3 blocks each taking 33% normally. When I resize the window to smaller size I would like the first two blocks to be stacked one above the other and take 50% of the width while the third element to span and take the other 50% on the whole but I am only able to span first two blocks in first row and third block in 2nd row.
And on minimizing it further, I would like all of them to be stacked one below the other.
I have added the layouts:
Here is my code:
li.listChild .time-home {
float: left;
height: auto;
width: 100%;
line-height: 21px;
font-size: 12px;
font-weight: 700;
text-align: right;
}
#media only screen and (min-width: 800px) and (max-width: 1023px) {
li.listChild .time-home {
width: 100%; }
}
li.listChild .time-home .listItem {
float: left; }
li.listChild .time-home .listItem.datum-home {
width: 33%;
font-weight: 700; }
#media only screen and (min-width: 1024px) and (max-width: 1443px) {
li.listChild .time-home .listItem.datum-home {
width: 50%;
border-bottom: 1px #e8e8e8 solid; }
}
#media only screen and (min-width: 800px) and (max-width: 1023px) {
li.listChild .time-home .listItem.datum-home {
width: 100%;
border-bottom: 1px #e8e8e8 solid; }
}
li.listChild .time-home .listItem.zeit-home {
font-weight: 400;
width: 33%;
}
#media only screen and (min-width: 1024px) and (max-width: 1443px) {
li.listChild .time-home .listItem.zeit-home {
width: 50%;
border-bottom: 1px #e8e8e8 solid; }
}
#media only screen and (min-width: 800px) and (max-width: 1023px) {
li.listChild .time-home .listItem.zeit-home {
width: 100%;
border-bottom: 1px #e8e8e8 solid; }
}
li.listChild .time-home .listItem.type-home {
width: 33%;
color: #0293ed;
border: none;
font-weight: 700;
}
#media only screen and (min-width: 1024px) and (max-width: 1443px) {
li.listChild .time-home .listItem.type-home {
width: 100%;
border-bottom: 1px #e8e8e8 solid;
border-right: 1px #e8e8e8 solid; }
}
#media only screen and (min-width: 800px) and (max-width: 1023px) {
li.listChild .time-home .listItem.type-home {
width: 100%;
border-bottom: 1px #e8e8e8 solid;
border-right: 1px #e8e8e8 solid; }
}
<li class="listChild">
<div class="time">
<div class="listItem datum">
3.6.93
</div>
<div class="listItem zeit">
4.6.93
</div>
<div class="listItem type">
Thomas
</div>
</div>
</li>
You don't necessarily need to use flexbox, you could use absolute positioning.
Example: https://jsfiddle.net/yyuwmv1r/
* {
box-sizing: border-box;
}
.container {
height: 300px;
width: 100%;
position: relative;
}
.one,
.two,
.three {
border: 2px solid black;
height: 33.33%;
width: 100%;
float: left;
background: red;
}
.two {
background: blue;
}
.three {
background: green;
}
#media only screen and (min-width: 800px) and (max-width: 1200px) {
.one,
.two,
.three {
position: absolute;
}
.one {
top: 0;
left: 0;
height: 50%;
width: 50%;
}
.two {
top: 50%;
left: 0;
height: 50%;
width: 50%;
}
.three {
top: 0;
left: 50%;
height: 100%;
width: 50%;
}
}
#media only screen and (min-width: 1200px) {
.one,
.two,
.three {
border: 2px solid black;
height: 100%;
width: 33.33%;
float: left;
background: red;
}
.two {
background: blue;
}
.three {
background: green;
}
}
<div class="container">
<div class="one">
One
</div>
<div class="two">
Two
</div>
<div class="three">
Three
</div>
</div>
You can do this with Flexbox and media queries
DEMO
.div-1, .div-2, .div-3 {
border: 1px solid black;
}
.content {
display: flex;
flex-direction: row;
min-height: 100vh;
}
.group {
flex: 2;
display: flex;
}
.div-3, .div-1, .div-2 {
flex: 1;
}
#media(max-width: 992px) {
.group {
flex-direction: column;
}
}
#media(max-width: 480px) {
.content {
flex-direction: column;
}
}
<div class="content">
<div class="group">
<div class="div-1">Div 1</div>
<div class="div-2">Div 2</div>
</div>
<div class="div-3">Div 3</div>
</div>
Drag the output left and right to simulate media queries. Keep in mind I didn't abide by your media queries, was using my own only to simulate the example.
Fiddle here
<li class="listChild">
<div class="time">
<div class="some-container">
<div class="listItem datum">
list one
</div>
<div class="listItem zeit">
list two
</div>
</div>
<div class="listItem type">
list three
</div>
</div>
</li>
* {
box-sizing: border-box;
}
.listItem {
border: 1px solid #000;
padding: 10px;
float: left;
width: 250px;
height: 30px;
}
.some-container {
float: left;
}
.some-container + .listItem {
float: left;
}
#media (max-width: 800px) and (min-width: 300px) {
.some-container .listItem {
height: 30px;
float: none;
}
.some-container + .listItem {
height: 60px;
}
}
#media (max-width: 299px) {
.listItem {
float: none;
width: 100%;
}
}
Related
I have the left & right columns, I want the image to be responsive when I minimize the screen & by default both left & right should cover the whole screen. when I minimize the screen the right image becomes small & when I check on the mobile device the left column is covering 80% of the screen. Please help me to fix the responsive image & what I'm missing. Below is my code.
div.container {
mc-grid-row: true;
margin-left: auto;
margin-right: auto;
display: flex;
flex-wrap: wrap;
justify-content: center;
width: 100%
}
div.box {
position: relative;
box-sizing: border-box;
margin-bottom: 0;
width: 50%;
min-width: 300px;
}
* {
box-sizing: border-box;
outline: 0;
padding: 0;
margin: 0;
}
body {
margin: 0;
}
.col-left{
background: #efefef;
box-shadow: 16px 0px 26px rgba(0, 0, 0, 0.3);
width:50%;
height:auto;
}
.col-right{
width:50%;
height:auto;
}
.col-right img {
width:100%;
height:auto;
background-repeat:no-repeat;
background-size:cover;
background-position:center center;
}
.container{
position:relative;
left:126px;
}
label {
display: inline-block;
max-width: 100%;
}
.container .main:after {
clear: both;
display: block;
content: '';
}
.main{
margin-left: 43px;
width: 547px;
height: 120px;
}
.content{
position:relative;
left: 126px;
margin-top:175px;
}
.text{
width: 547px;
height: 213px;
}
.title{
font-family: 'Inter';
font-style: italic;
font-weight: 300;
font-size: 36px;
line-height: 44px;
letter-spacing: 0.005em;
color: #FFFFFF;
}
.container{
margin-top:162px;
}
.author{
font-family: 'Inter-Regular';
font-style: normal;
font-weight: 600;
font-size: 28px;
line-height: 33px;
color: #FFFFFF;
margin-top:48px;
}
#media only screen and (min-width: 638px) and (max-width: 1334px) {
.title{
font-size:33px;
}
}
#media only screen and (min-width: 638px) and (max-width: 1251px) {
.title{
font-size:32px;
}
}
#media only screen and (min-width: 638px) and (max-width: 1171px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 1130px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 1056px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 994px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 987px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 942px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 838px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 811px) {
.ls-title{
font-size: 18px;
width: 320px;
}
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 760px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 638px) and (max-width: 709px) {
.title{
font-size:30px;
}
}
#media only screen and (min-width: 375px) and (max-width: 680px) {
.container .main:before {
width: 12px;
height: 64px;
}
.container{
left:40px;
}
.ls-logo-wrap{
left:40px;
}
.main{
margin-left:24px;
}
.content {
left: 40px;
margin-top: 43px;
}
.title{
font-size:18px;
width:280px;
line-height:28px;
}
.author{
margin-top:16px;
font-size:18px;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="col-left box">
<div class="container">
<div class="main">
<label class="title">textheretextherertexthere</label>
</div>
</div>
<div class="content">
<div class="text">
<label class="title">textheretextheretextheretextheretextheretexthere</label>
</div>
</div>
</div>
<div class="col-right box">
<img src="http://img.huffingtonpost.com/asset/scalefit_600_noupscale/56328113190000a600b9540d.jpeg" />
</div>
</div>
This code snippet will help you to solve your problem! check it out If you need any help let me know :)
I have noticed you were using the same classes "title" inside two different fields maybe it can impact your styling sometimes :)
Also, you were using a lot of media queries which were not needed as I believe. You can learn more about RWD here :)
https://css-tricks.com/a-complete-guide-to-css-media-queries/
.container {
display: flex;
/* flex-direction: row;
height: min-content; */
}
.box {
position: relative;
box-sizing: border-box;
margin-bottom: 0;
}
* {
box-sizing: border-box;
outline: 0;
padding: 0;
margin: 0;
}
body {
margin: 0;
}
.col-left{
background: black;
box-shadow: 16px 0px 26px rgba(0, 0, 0, 0.3);
width:50%;
}
.col-right{
width:50%;
height:auto;
}
.col-right img {
width:100%;
height:auto;
background-repeat:no-repeat;
background-size:cover;
background-position:center center;
}
label {
display: inline-block;
max-width: 100%;
}
.container .main:after {
clear: both;
display: block;
content: '';
}
.main{
text-align: center;
height: 120px;
}
.text{
text-align: center;
height: 213px;
}
.title{
font-family: 'Inter';
font-style: italic;
font-weight: 300;
font-size: 36px;
line-height: 44px;
letter-spacing: 0.005em;
color: #FFFFFF;
overflow-wrap: break-word;
padding: 5px;
}
.author{
font-family: 'Inter-Regular';
font-style: normal;
font-weight: 600;
font-size: 28px;
line-height: 33px;
color: #FFFFFF;
margin-top:48px;
}
#media (max-width: 800px)
{
.container{
flex-direction: column;
text-align: center;
align-items: center;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="col-left box">
<!-- here you have used the same class which is not a correct way to use -->
<div class="containers">
<div class="main">
<label class="title">textheretextherertexthere</label>
</div>
</div>
<div class="content">
<div class="text">
<label class="title">textheretextheretextheretextheretextheretexthere</label>
</div>
</div>
</div>
<div class="col-right box">
<img src="http://img.huffingtonpost.com/asset/scalefit_600_noupscale/56328113190000a600b9540d.jpeg" />
</div>
</div>
This question already has answers here:
Max-Width vs. Min-Width
(7 answers)
Closed 2 years ago.
I'm having some issues with min-width media queries. Right now everything works exactly as designed until the window screen becomes less than 375px. Once the screen goes less than this, .list__content reappears. Does anyone know how once it goes under 375px, it goes disappears?
Where is what I am hoping:
The window is less than or equal to 375px
🚫 .list__content dissapears
✅ .list__items 100% width
The window is between 375px and 768px
✅ .list__items, .list__content 50% width
The window is greater than 768px
✅ .list__items 33% and .list__content is 66%
.list {
position: absolute;
height: 100%;
width: 100%;
background-color: #fff;
display: flex;
}
.list__items,
.list__content {
position: relative;
}
.list__items_header,
.list__content_header {
border-bottom: 1px solid black;
padding: 5px;
}
.list__items {
width: 100%;
border: 0;
}
.list__content {
width: 100%;
display: block;
}
#media (min-width: 375px) {
.list__items {
width: 100%;
border-right: 0;
}
.list__content {
display: none;
}
}
#media (min-width: 768px) {
.list__items {
width: 50%;
border-right: 1px solid black;
}
.list__content {
width: 50%;
display: block;
}
}
#media (min-width: 1032px) {
.list__items {
width: 33%;
border-right: 1px solid black;
}
.list__content {
width: 66%;
display: block;
}
}
<div class="list">
<div class="list__items">
<div class="list__items_header">i-h</div>
items
</div>
<div class="list__content">
<div class="list__content_header">c-h</div>
content
</div>
</div>
You are setting display: none; in .list__content for media query min-width: 375px, but you need to set that for max-width: 375px. The reason is that:
max-width: 375px means 375px and down
min-width: 375px means 375px and up
.list {
position: absolute;
height: 100%;
width: 100%;
background-color: #fff;
display: flex;
}
.list__items,
.list__content {
position: relative;
}
.list__items_header,
.list__content_header {
border-bottom: 1px solid black;
padding: 5px;
}
.list__items {
width: 100%;
border: 0;
}
.list__content {
width: 100%;
display: none;
}
#media (max-width: 375px) {
.list__items {
width: 100%;
border-right: 0;
}
.list__content {
display: none;
}
}
#media (min-width: 375px) {
.list__items {
width: 50%;
border-right: 1px solid black;
}
.list__content {
width: 50%;
display: block;
}
}
#media (min-width: 768px) {
.list__items {
width: 33%;
border-right: 1px solid black;
}
.list__content {
width: 66%;
display: block;
}
}
<div class="list">
<div class="list__items">
<div class="list__items_header">i-h</div>
items
</div>
<div class="list__content">
<div class="list__content_header">c-h</div>
content
</div>
</div>
I changed some of the CSS code. This is how you can do it :
.list {
position: absolute;
height: 100%;
width: 100%;
background-color: #fff;
display: flex;
}
.list__items,
.list__content {
position: relative;
}
.list__items_header,
.list__content_header {
border-bottom: 1px solid black;
padding: 5px;
}
.list__items {
width: 100%;
border-right: 1px solid black;
}
.list__content {
width: 100%;
display: block;
}
#media (max-width: 768px) {
.list__items {
width: 50%;
}
.list__content {
width: 50%;
display: block;
}
}
#media (max-width: 375px) {
.list__items {
width: 100%;
border-width: 0;
}
.list__content {
display: none;
}
}
#media (min-width: 1032px) {
.list__items {
width: 33%;
}
.list__content {
width: 66%;
display: block;
}
}
<div class="list">
<div class="list__items">
<div class="list__items_header">i-h</div>
items
</div>
<div class="list__content">
<div class="list__content_header">c-h</div>
content
</div>
</div>
I have 3 dropdown buttons, on mobile view instead of displaying horizontally they are overlapping on each other. I think .filter-check:checked+label class properties needs to be reviewed. What changes can I make in my code so that buttons are displayed horizontally?
Here is my scss code
#media (min-width: 700px) {
.filter-button {
display: none;
}
.filter-check {
display: none;
}
}
#media (max-width: 700px) {
.filter {
display: none;
}
.filter-check {
display: none;
}
}
#media screen and (max-width: 700px) {
.filter-button {
background: white;
border: 1px solid black;
border-radius: 2px;
color: dark-gray;
float: right;
font-family: font-family-nimbus-sans-bold;
font-size: 18px;
height: 48px;
text-align: left;
width: 100%;
}
}
// sass-lint:disable force-pseudo-nesting
.filter-check:checked+label { ---------------> I think this class properties needs to be checked
+.filters {
.filter {
background-color: white;
display: block;
height: 100%;
left: 0;
overflow-y: auto;
padding-bottom: 65px;
position: fixed;
top: 0;
width: 100%;
}
::ng-deep {
.overlay-drop {
height: auto;
position: relative;
}
.open {
ul {
position: relative;
top: auto;
}
}
}
}
}
.filters {
display: flex;
flex-wrap: wrap;
#media screen and (min-width: 700px) {
.filter {
background-color: white;
border: 1px solid black;
border-radius: 2px;
flex-basis: 100%;
flex-grow: 1;
flex-shrink: 1;
height: 72px;
margin-right: 10px;
max-width: 224px;
&.disabled {
border-color: silver-chalice;
color: silver-chalice;
opacity: .4;
pointer-events: none;
&:hover {
cursor: no-drop;
}
}
}
}
}
Here is my html code
<ng-container>
<label class="filter-button" for="button" (click)="xy()">Coders</label>
<div class="filters">
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="a">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="b">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="c">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="shareClassData"></overlay-drop>
</div>
</div>
</ng-container>
/ng-container>
Try this code for scss
#media (min-width: 700px) {
.filter-button {
display: none;
}
.filter-check {
display: none;
}
}
#media (max-width: 700px) {
.filter-check {
display: none;
}
}
.filter-button {
background: white;
border: 1px solid black;
border-radius: 2px;
color: dark-gray;
float: none;
font-family: font-family-nimbus-sans-bold;
font-size: 18px;
height: 48px;
text-align: left;
width: 100%;
}
// sass-lint:disable force-pseudo-nesting
.filter-check:checked+label {
+.filters {
.filter {
background-color: white;
display: block;
height: 100%;
left: 0;
overflow-y: auto;
padding-bottom: 65px;
position: fixed;
top: 0;
width: 100%;
}
::ng-deep {
.overlay-drop {
height: auto;
position: relative;
}
.open {
ul {
position: relative;
top: auto;
}
}
}
}
}
.filters {
display: flex;
.filter {
background-color: white;
border: 1px solid black;
border-radius: 2px;
flex-basis: 100%;
flex-grow: 1;
flex-shrink: 1;
height: 72px;
margin-right: 10px;
max-width: 224px;
&.disabled {
border-color: silver-chalice;
color: silver-chalice;
opacity: .4;
pointer-events: none;
&:hover {
cursor: no-drop;
}
}
}
}
<ng-container>
<label class="filter-button" for="button" (click)="xy()">Coders</label>
<div class="filters">
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="a">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="b">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="c">
</overlay-drop>
</div>
<div class="filter">
<overlay-drop [dropdownLabel]="i18nService"
[modelDropdown]="shareClassData"></overlay-drop>
</div>
</div>
</ng-container>
I want to put a timeline in my website which I found on codepen.
The problem is, it has only three sections(semantic, relative, contained), I tried to add another two sections but the layout gets disrupted and loses responsiveness.
Could anyone guide me in creating extra sections in that timeline without loosing it's 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 -->
</section>
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;
}
}
Your CSS needs to be modified to include more divs within the same width. Now since the divs are manually assigned spacing between them rather than a dynamic approach, you can experimentally change the width and margin properties and including .step-four & .step-five in the css as well. I've included one additional div for example. You can try out adding more in this way.
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: 0px;
}
#media screen and (min-width: $break-point) {
border-top: 2px solid $brand-primary;
padding-top: 20px;
margin-top: 40px;
margin-left: 10%;
margin-right: 10%;
}
&:after {
content: "";
display: table;
clear: both;
}
}
.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five{
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: 25%;
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: -12%;
margin-right: 12%;
}
}
.steps-two {}
.steps-three,.step-four{
#media screen and (max-width: $break-point) {
margin-bottom: -100%;
}
#media screen and (min-width: $break-point) {
margin-left: 10%;
margin-right: -10%;
float:right;
}
}
.steps-img {
display: block;
margin: auto;
width: 50px;
height: 50px;
border-radius: 50%;
#media screen and (max-width: $break-point) {
float: left;
margin-right: 10px;
}
}
.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;
}
}
Depending on the number of divs, the width property of the following can be changed.
.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five{
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: 25%;
margin-top: -50px;
}
}
For Example
3 divs - 33%
4 divs - 25%
5 divs - 20%
and so on
I need 6 steps. I tried for hours, I just can't make it work. I'm pretty sure it's not that hard for someone more experienced. I've had several forks but all are dead end.
Could you help me out please?
http://codepen.io/kjohnson/pen/azBvaE
HTML:
<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:
#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;
}
.section-header, .steps-header, .steps-name {
color: #3498DB;
font-weight: 400;
font-size: 1.4em;
}
.steps-header {
margin-bottom: 20px;
text-align: center;
}
.steps-timeline {
outline: 1px dashed rgba(255, 0, 0, 0);
}
#media screen and (max-width: 500px) {
.steps-timeline {
border-left: 2px solid #3498DB;
margin-left: 25px;
}
}
#media screen and (min-width: 500px) {
.steps-timeline {
border-top: 2px solid #3498DB;
padding-top: 20px;
margin-top: 40px;
margin-left: 16.65%;
margin-right: 16.65%;
}
}
.steps-timeline:after {
content: "";
display: table;
clear: both;
}
.steps-one,
.steps-two,
.steps-three {
outline: 1px dashed rgba(0, 128, 0, 0);
}
#media screen and (max-width: 500px) {
.steps-one,
.steps-two,
.steps-three {
margin-left: -25px;
}
}
#media screen and (min-width: 500px) {
.steps-one,
.steps-two,
.steps-three {
float: left;
width: 33%;
margin-top: -50px;
}
}
#media screen and (max-width: 500px) {
.steps-one,
.steps-two {
padding-bottom: 40px;
}
}
#media screen and (min-width: 500px) {
.steps-one {
margin-left: -16.65%;
margin-right: 16.65%;
}
}
#media screen and (max-width: 500px) {
.steps-three {
margin-bottom: -100%;
}
}
#media screen and (min-width: 500px) {
.steps-three {
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: 500px) {
.steps-img {
float: left;
margin-right: 20px;
}
}
.steps-name,
.steps-description {
margin: 0;
}
#media screen and (min-width: 500px) {
.steps-name {
text-align: center;
}
}
.steps-description {
overflow: hidden;
}
#media screen and (min-width: 500px) {
.steps-description {
text-align: center;
}
}
I assume you want something like this?
http://codepen.io/adamk22/pen/LGQQKz
$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: 8%;
margin-right: 8%;
}
&:after {
content: "";
display: table;
clear: both;
}
}
.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five,
.steps-six{
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: 12%;
margin-top: -50px;
}
}
.steps-one,
.steps-two,
.steps-three,
.steps-four,
.steps-five,
.steps-six{
#media screen and (max-width: $break-point) {
padding-bottom: 40px;
}
}
.steps-one {
#media screen and (min-width: $break-point) {
margin-left: -8%;
margin-right: 8%;
}
}
.steps-two {
#media screen and (min-width: $break-point) {
margin-right: 8%;
}
}
.steps-three {
#media screen and (min-width: $break-point) {
margin-right: 8%;
}
}
.steps-four {
#media screen and (min-width: $break-point) {
margin-right: 8%;
}
}
.steps-five {
}
.steps-six {
#media screen and (max-width: $break-point) {
margin-bottom: -100%;
}
#media screen and (min-width: $break-point) {
margin-left: 8%;
margin-right: -8%;
}
}
.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;
}
}
Most of the changes require you to change the CSS, especially the media queries as you can see in the pen.