I am using css grid where I have a card inside a sidebar div that is inside a container dive. I am also using a inner-container div where I put 3 cards. The sidebar div card has proper width but the cards inside the inner-container do not adjust to 200px. How can I give the inner-container cards a specific width.
HTML
<aside class="sidebar">
<h2><b>Latest Blog Post</b></h2>
<div class="card">
<img class="card-image" src="images/christmas.jpeg" alt="christmas-markets" width="100%">
<div class="card-text">
<p>German Christmas Markets</p>
</div>
</div>
</aside>
<article class="main">
<h1>An American Living in Germany</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
<div class=".inner-container">
<div class="card"><img class="card-image" src="images/pubic-transit.jpeg" alt="public-transit" width="100%">
<div class="card-text">
<p>Public Transit</p>
</div></div>
<div class="card"><img class="card-image" src="images/rothenburg.jpeg" alt="christmas-markets" width="100%">
<div class="card-text">
<p>Rothenburg ob der Tauber</p>
</div></div>
<div class="card"><img class="card-image" src="images/black-forest.jpeg" alt="public-transit" width="100%">
<div class="card-text">
<p>The Black Forest</p>
</div></div>
</div>
</article>
CSS
.card {
box-shadow: 0 8px 8px 8px rgba(0,0,0,0.2);
transition: 0.3s;
width: 90%;
height: auto;
border-radius: 5px;
margin-top: 20px;
}
.card-text {
padding: 2px;
margin-left: 5px;
margin-bottom: 2px;
margin-top: 5px;
line-height: .5em;
}
.card-text a {
color: crimson;
font-size: 1.2em;
}
.card-image {
width: 100%;
bottom: 0px;
}
.inner-container {
height: 50%;
width: 80%;
display: grid;
grid-template-columns: 200px 200px 200px;
grid-template-rows: 200px 200px 200px;
grid-template-areas:
"b b b";
}
.inner-container div {
grid-area: b;
}
.inner-container .card{
box-shadow: 0 8px 8px 8px rgba(0,0,0,0.2);
transition: 0.3s;
width: 200px;
height: auto;
border-radius: 5px;
margin-top: 20px;
}
.inner-container .card-text {
padding: 2px;
margin-left: 5px;
margin-bottom: 2px;
margin-top: 5px;
line-height: .5em;
}
.inner-container .card-text a {
color: crimson;
font-size: 1.2em;
}
.inner-container .card-image {
width: 100%;
bottom: 0px;
}
You've got a typo in your code which is why CSS isn't firing for that class.
<div class=".inner-container">
should be
<div class="inner-container">
Also took the liberty of adding grid-area:auto; to css to make it render properly for you:
Working fiddle: https://jsfiddle.net/ne6vrwyq/
.card {
box-shadow: 0 8px 8px 8px rgba(0,0,0,0.2);
transition: 0.3s;
width: 90%;
height: auto;
border-radius: 5px;
margin-top: 20px;
}
.card-text {
padding: 2px;
margin-left: 5px;
margin-bottom: 2px;
margin-top: 5px;
line-height: .5em;
}
.card-text a {
color: crimson;
font-size: 1.2em;
}
.card-image {
width: 100%;
bottom: 0px;
}
.inner-container {
height: 50%;
width: 80%;
display: grid;
grid-template-columns: 200px 200px 200px;
grid-template-rows: 200px 200px 200px;
grid-template-areas:
"b b b";
}
.inner-container div {
grid-area: b;
}
.inner-container .card{
box-shadow: 0 8px 8px 8px rgba(0,0,0,0.2);
transition: 0.3s;
width: 200px;
height: auto;
border-radius: 5px;
margin-top: 20px;
grid-area: auto;
}
.inner-container .card-text {
padding: 2px;
margin-left: 5px;
margin-bottom: 2px;
margin-top: 5px;
line-height: .5em;
}
.inner-container .card-text a {
color: crimson;
font-size: 1.2em;
}
.inner-container .card-image {
width: 100%;
bottom: 0px;
}
<aside class="sidebar">
<h2><b>Latest Blog Post</b></h2>
<div class="card">
<img class="card-image" src="images/christmas.jpeg" alt="christmas-markets" width="100%">
<div class="card-text">
<p>German Christmas Markets</p>
</div>
</div>
</aside>
<article class="main">
<h1>An American Living in Germany</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
<div class="inner-container">
<div class="card"><img class="card-image" src="images/pubic-transit.jpeg" alt="public-transit" width="100%">
<div class="card-text">
<p>Public Transit</p>
</div></div>
<div class="card"><img class="card-image" src="images/rothenburg.jpeg" alt="christmas-markets" width="100%">
<div class="card-text">
<p>Rothenburg ob der Tauber</p>
</div></div>
<div class="card"><img class="card-image" src="images/black-forest.jpeg" alt="public-transit" width="100%">
<div class="card-text">
<p>The Black Forest</p>
</div></div>
</div>
</article>
Related
I'm trying to place an image in a circle div that's placed above a section containing text like in the image shown:
How can this be done using CSS? Thank you.
Run the Code Here
https://www.w3schools.com/code/tryit.asp?filename=GHOLRSYI9PEK
.flex-wrapper{
background-color: lightgray;
padding: 30px;
padding: 30px 30px 30px 100px;
}
.flex-container {
display: flex;
background-color: #f1f1f1;
}
.flex-container > div {
margin: 10px;
padding: 10px;
font-size: 16px;
}
.flex-container{
-webkit-box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
-moz-box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
}
.avatar-wrapper{
min-width: 150px;
position: relative;
margin-left: -50px !important;
margin: 10px;
padding: 10px;
font-size: 16px;
height: 150px;
display: flex;
align-items: center;
justify-content: center;
}
.avatar-wrapper:after{
content: '';
height: calc(100% + 40px);
width: calc(100% + 40px);
position: absolute;
background: purple;
top: -20px;
left: -20px;
border-radius: 50%;
z-index: 0;
}
.avatar-wrapper > img{
width: 150px;
height: 150px;
z-index: 1;
position: relative;
border-radius: 50%;
}
<div class="flex-wrapper">
<div class="flex-container">
<div class="col avatar-wrapper">
<img src="https://via.placeholder.com/200" alt="sample">
</div>
<div class="col text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</div>
</div>
</div>
img{ border-radius:50%; z-index:1 }
.container{
z-index:0;
margin-left:-100px;
box-shadow: 0px 0px 10px 1px lightgrey;
padding:5px;
width:50%;
}
.text{
text-decoration:underline blue;
margin-left:100px;
}
<div style="display:flex;">
<img src="https://via.placeholder.com/250">
<div class="container">
<div class="text">
I'm trying to place an image in a circle div that's placed above a section containing text like in the image shown:
</div>
</div>
</div>
Here is your solution. Just add your Image url in img tag
I'm pretty much stuck with making side menu div's of my code filling the parent height to 100%. I've tried alot of googling and testing before comming to ask..
Code snippet: http://jsfiddle.net/zntxaspd/
html, body { height: 100%;}
.row.content { height: 100%; width:70%; margin: auto; }
.sidenav { padding-top: 20px;background-color: #f1f1f1; height: 100%;}
#media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;}
}
h5 { font-size: 14px; border-bottom: 6px solid red; font-weight: bold; }
.rightcontainer { width:100%; height:100% margin: auto; border: 0px solid; border-radius: 4px; margin-bottom: 5px; border-bottom: 6px solid red;}
.rightcontainer .accountpanel .columncontainer .col-sm-6 { padding-right: 0px; padding-left: 0px;}
.leftcontainer {width:100%; margin: auto; margin-bottom: 5px; border-bottom: 6px solid red; }
.leftcontainer .eventinfo {width:100%; height: 38px; margin-bottom: 5px; border: 1px solid gray; }
.leftcontainer .eventinfo .split { height: 17px; }
.leftcontainer .eventinfo .split span { font-size: 12px; }
.leftcontainer .banner {width: 100%; height: 75px; border: 1px solid gray; margin-bottom: 5px; }
I can not understand why both side menu's are filling just the height of their own content instead of filling height of the parent div. Is there something I'm doing wrong? It fills fine if I dont add !DOCTYPE html to my project, but from what I understand its bad solution so I should find other way around..
Best regards
http://jsfiddle.net/zntxaspd/6/
Add display: flex;to .row.content:
.row.content { height: 100%; width:70%; margin: auto; display: flex; }
Add flex: 1; to .sidebar:
.sidenav { padding-top: 20px;background-color: #f1f1f1; flex: 1}
Adjust your media query to keep it responsive:
#media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto; display: block;}
}
Use bootstrap-4 CSS to achieve the desired result
Bootstrap 4
Also removed the extra row content div
html,
body {
height: 100%;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content {
height: 100%;
width: 70%;
margin: auto;
}
/* Set gray background color and 100% height */
.sidenav {
padding-top: 20px;
background-color: #f1f1f1;
height: 100%;
}
/* On small screens, set height to 'auto' for sidenav and grid */
#media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {
height: auto;
}
}
h5 {
font-size: 14px;
border-bottom: 6px solid red;
font-weight: bold;
}
.rightcontainer {
width: 100%;
height: 100% margin: auto;
border: 0px solid;
border-radius: 4px;
margin-bottom: 5px;
border-bottom: 6px solid red;
}
.rightcontainer .accountpanel .columncontainer .col-sm-6 {
padding-right: 0px;
padding-left: 0px;
}
.leftcontainer {
width: 100%;
margin: auto;
margin-bottom: 5px;
border-bottom: 6px solid red;
}
.leftcontainer .eventinfo {
width: 100%;
height: 38px;
margin-bottom: 5px;
border: 1px solid gray;
}
.leftcontainer .eventinfo .split {
height: 17px;
}
.leftcontainer .eventinfo .split span {
font-size: 12px;
}
.leftcontainer .banner {
width: 100%;
height: 75px;
border: 1px solid gray;
margin-bottom: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="container-fluid text-center">
<div class="row justify-content-center">
<div class="col-sm-2 sidenav">
<div class="leftcontainer">
<div class="banner"> Get Client Banner </div>
<div class="banner"> Guides Banner </div>
<h5> Event Schedule </h5>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0 H</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0 Hr</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0 Hr n</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>B</strong></span></div>
<div class="split"><span>0 D 0 </span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0</span></div>
</div>
<div class="eventinfo">
<div class="split"><span><strong>Bl</strong></span></div>
<div class="split"><span>0 D 0 </span></div>
</div>
</div>
</div>
<div class="col-sm-7 text-left">
<h1>Welcome</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.</p>
<hr>
<h3>Test</h3>
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-3 sidenav">
<div class="well">
<p>ADS</p>
</div>
<div class="well">
<p>ADS</p>
</div>
</div>
</div>
</div>
When I add two section in my page the sidebar vertically equals the
second section, I need my first section and aside to be vertically equal.
How do I accomplish this? I tried float: left on Section 1 and display: inline on the parent section, but those seemed to cause aside to "break out".
when I add two section in my page the sidebar vertically equals the
second section, I need my first section and aside to be vertically equal.
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block;
}
* {
margin: 0;
padding: 0;
}
a {
color: #444;
}
body,
html {
width: 100%;
overflow-x: hidden;
width: 100%;
margin: 0;
padding: 0
}
body {
background: #f7f7f7;
min-height: 100%;
height: auto;
position: relative;
font-family: 'Roboto', sans-serif;
line-height: normal;
font-weight: normal;
font-size: 1em;
}
.site-header {
position: relative;
z-index: 99;
float: left;
width: 100%;
margin-bottom: 20px;
padding: 0;
background: #FFF;
}
#page,
.container {
width: 1124px;
min-width: 240px;
position: relative;
margin-right: auto;
margin-left: auto;
}
.header-inner {
width: 100%;
height: 100%;
display: table;
padding: 1% 0;
}
.secondary-navigation {
background: #17aa1c;
}
a:link,
a:visited,
a:active {
text-decoration: none;
}
a:active,
a:hover {
outline: 0;
}
.main-navigation ul li {
display: inline-block;
padding-top: 19px;
padding-bottom: 19px;
padding-left: 20px;
padding-right: 20px;
text-decoration: none;
}
.main-navigation ul li a {
color: #fff;
}
.main-navigation ul li a:hover {
color: #ff9;
}
.secondary-navigation {
width: 100%!important;
}
.content-area {
width: 55%;
float: left;
margin-left: 100px;
margin-right: 1%;
margin-bottom: 20px;
background: #FFF;
padding: 0 10px;
-webkit-box-shadow: 0 1px 1px #c2c4c4;
-moz-box-shadow: 0 1px 1px #c2c4c4;
box-shadow: 0 1px 1px #c2c4c4;
text-shadow: 0 1px 1px #FFF;
clear: both;
}
.aside {
float: left;
width: 20%;
margin-bottom: 20px;
background: #FFF;
padding: 0 10px;
text-shadow: 0 1px 1px #FFF;
}
.inner {
padding: 10px;
}
.title {
font-weight: 500;
color: #444;
text-transform: uppercase;
margin: 0;
}
.post-info {
display: inline-table;
color: #919191;
float: left;
clear: both;
width: 100%;
}
.post-info>span {
display: inline-block;
font-size: 0.9em;
padding: 10px;
color: #919191;
text-transform: uppercase;
}
<section class="content-area">
<article>
<div class="inner">
<h2 class="title">sasasasanostrud exercitation ullamco laboris nisi ut aliquip</h2>
<div class="post-info">
<span>Posted</span>
<span>Category</span>
<span>Date</span>
</div>
<p>ipsum dolor sit amet, consectetur adipisicing elit, sed do quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
</p>
<div class="readmore">Readmore</div>
</div>
</article>
</section>
<section id="primary" class="content-area">
<div class="inner">
<h2 class="title">sasasasanostrud exercitation ullamco laboris nisi ut aliquip</h2>
<div class="post-info">
<span>Posted</span>
<span>Category</span>
<span>Date</span>
</div>
<p>ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
</p>
<div class="readmore">Readmore</div>
</div>
</section>
<aside class="aside ">
<div class="inner">
<h3>Popular Posts</h3>
<ul>
<li>tempor incididunt ut labore et doloreincididunt ut labore et</li>
<li>tempor incididunt ut labore et dolore</li>
<li>tempor incididuntincididunt ut labore et ut labore et dolore</li>
</ul>
</div>
</aside>
Just wrap elements into flex-container and remove float: left. Demo:
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block;
}
* {
margin: 0;
padding: 0;
}
a {
color: #444;
}
body,
html {
width: 100%;
overflow-x: hidden;
width: 100%;
margin: 0;
padding: 0
}
body {
background: #f7f7f7;
min-height: 100%;
height: auto;
position: relative;
font-family: 'Roboto', sans-serif;
line-height: normal;
font-weight: normal;
font-size: 1em;
}
.site-header {
position: relative;
z-index: 99;
float: left;
width: 100%;
margin-bottom: 20px;
padding: 0;
background: #FFF;
}
#page,
.container {
width: 1124px;
min-width: 240px;
position: relative;
margin-right: auto;
margin-left: auto;
}
.header-inner {
width: 100%;
height: 100%;
display: table;
padding: 1% 0;
}
.secondary-navigation {
background: #17aa1c;
}
a:link,
a:visited,
a:active {
text-decoration: none;
}
a:active,
a:hover {
outline: 0;
}
.main-navigation ul li {
display: inline-block;
padding-top: 19px;
padding-bottom: 19px;
padding-left: 20px;
padding-right: 20px;
text-decoration: none;
}
.main-navigation ul li a {
color: #fff;
}
.main-navigation ul li a:hover {
color: #ff9;
}
.secondary-navigation {
width: 100%!important;
}
.content-area {
width: 55%;
margin-left: 100px;
margin-right: 1%;
margin-bottom: 20px;
background: #FFF;
padding: 0 10px;
-webkit-box-shadow: 0 1px 1px #c2c4c4;
-moz-box-shadow: 0 1px 1px #c2c4c4;
box-shadow: 0 1px 1px #c2c4c4;
text-shadow: 0 1px 1px #FFF;
clear: both;
}
.aside {
width: 20%;
margin-bottom: 20px;
background: #FFF;
padding: 0 10px;
text-shadow: 0 1px 1px #FFF;
}
.inner {
padding: 10px;
}
.title {
font-weight: 500;
color: #444;
text-transform: uppercase;
margin: 0;
}
.post-info {
display: inline-table;
color: #919191;
float: left;
clear: both;
width: 100%;
}
.post-info>span {
display: inline-block;
font-size: 0.9em;
padding: 10px;
color: #919191;
text-transform: uppercase;
}
.flex {
display: flex;
}
<div class="flex">
<section class="content-area">
<article>
<div class="inner">
<h2 class="title">sasasasanostrud exercitation ullamco laboris nisi ut aliquip</h2>
<div class="post-info">
<span>Posted</span>
<span>Category</span>
<span>Date</span>
</div>
<p>ipsum dolor sit amet, consectetur adipisicing elit, sed do quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
</p>
<div class="readmore">Readmore</div>
</div>
</article>
</section>
<aside class="aside ">
<div class="inner">
<h3>Popular Posts</h3>
<ul>
<li>tempor incididunt ut labore et doloreincididunt ut labore et</li>
<li>tempor incididunt ut labore et dolore</li>
<li>tempor incididuntincididunt ut labore et ut labore et dolore</li>
</ul>
</div>
</aside>
</div>
<section id="primary" class="content-area">
<div class="inner">
<h2 class="title">sasasasanostrud exercitation ullamco laboris nisi ut aliquip</h2>
<div class="post-info">
<span>Posted</span>
<span>Category</span>
<span>Date</span>
</div>
<p>ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
</p>
<div class="readmore">Readmore</div>
</div>
</section>
I'm having a problem creating a responsive "card" similar to the Custom Content Thumbnail in Bootstrap but horizontal. The main problem is that I want the image to be a square and 100% of the height of the card. Also, I want all the cards to have the same width and height.
This is my work so far:
body {
background-color:#ededed;
font-family:"Segoe UI";
}
/*----------2.Headings & Buttons----------*/
h3 {
font-size:1.2em;
font-weight:600;
text-transform:capitalize;
margin:0 0 10px 0;
padding:0;
color:#555555;
}
.btn-styled {
background-color:transparent;
border:#666666 1.9px solid;
color:#666666;
font-size:0.85em;
border-radius:30px;
padding:5px 13px 4px 13px;
margin:10px 0 10px 0;
}
.btn-styled:hover, .btn-styled:active {
background-color:#ededed;
border-color:#ededed;
color:#555555;
}
.btn-styled:focus {
outline:0 !important;
}
/*----------3.Cards----------*/
.card {
position: relative;
margin:2% 5px 2% 5px;
background-color: #fff;
transition: box-shadow .25s;
border-radius: 2px;
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);
padding:0;
min-width:400px;
max-width:500px;
}
.card .card-image img {
display: block;
border-radius: 2px 2px 0 0;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
}
.card .card-content {
padding: 15px 10px 0 0;
border-radius: 0 0 2px 2px;
}
.card .card-content p {
margin:0;
font-size:1.45rem;
color: #555555;
}
/*----3.a.Horizontal----*/
.card.horizontal .card-image img {
height:100px;
width:100px;
}
.card.horizontal {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.card.horizontal.small .card-image,
.card.horizontal.medium .card-image,
.card.horizontal.large .card-image {
height: 100%;
max-height: none;
overflow: visible;
}
.card.horizontal .card-image img {
width:150px;
height:150px;
margin-right:20px;
}
.card.horizontal .card-stacked {
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
position: relative;
}
.card.horizontal .card-stacked .card-content {
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
.card .card-image {
position: relative;
}
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>MAIN TITLE</h3>
</div>
</div>
<div class="row">
<div class="col-md-offset-1 col-md-5 col-xs-12">
<div class="card horizontal">
<div class="card-image">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/f/ff/Morning_Glory_Flower_square.jpg/1024px-Morning_Glory_Flower_square.jpg">
</div>
<div class="card-stacked">
<div class="card-content">
<h3>Title Goes Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed doeiusmod tempor incididunt.</p>
<button class="btn btn-styled">START COPY</button>
</div>
</div>
</div>
</div>
<div class="col-md-offset-1 col-md-5 col-xs-12">
<div class="card horizontal">
<div class="card-image">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/f/ff/Morning_Glory_Flower_square.jpg/1024px-Morning_Glory_Flower_square.jpg">
</div>
<div class="card-stacked">
<div class="card-content">
<h3>Title Goes Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed doeiusmod tempor incididunt.</p>
<button class="btn btn-styled">START COPY</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
Also, I made an example of how the cards should look in a grid:
When I tried to create this cards they were not responsive. On different screen widths the left-right-margin was too big or they were on top of each other.
Can someone help get started or give me some ideas how I should do it?
Thanks in advance.
use bootstrap. Ihave provided a demo link just experiment with the code and read the documentation of bootstrap to get better understanding
Here is your Demo Link
Html Code
<div class="container">
<div class="col-md-4">
<div class="card">
<div class="image pull-left">
</div>
<div class="content pull-left">
<h4>
Title Goes Here
</h4> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
<br>
<button class="btn btn-default btn-read">
Read more
</button>
</div>
<div class="clearfix">
</div>
</div>
</div>
</div>
Css code
.card {
background: #fff;
display: inline-block;
border: 1px solid #ddd;
}
.image {
float: left;
background: #000;
width: 25%;
height: 150px
}
.content {
float: left;
height: 140px;
width: 73%;
overflow: hidden;
padding: 5px;
}
.content h4 {
margin: 5px 0;
}
I'm working on this block of HTML CSS, I need the image to overlap slightly the header div (in blue).
I'm doing this as shown in the jsfiddle here: https://jsfiddle.net/49zcmf4z/3/
the HTML
<div class="container">
<div class="row">
<div class="col-md-12 block-header">
<div class="col-md-offset-6 col-md-6 text-center block-header">
<h1>Title</h1>
</div>
</div>
<div class="row">
<div class="col-md-6 image text-center">
<img src="http://placehold.it/350x150">
</div>
<div class="col-md-6">
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</div>
</div>
</div>
</div>
</div>
and the CSS
body {
margin: 10px;
}
.container {
border: solid 1px red;
}
.image {
position: relative;
z-index: 10;
}
#media (min-width: 200px) {
.image img {
transform: translateY(-5em);
}
}
.image img {
width: 100%;
border: solid 1px black;
margin-left: 1em;
}
.block-header {
background-color: blue;
height: 85px;
padding-left: 0px;
padding-right: 0px;
}
#media (max-width: 992px) {
.block-header {
padding-top: 1px;
}
}
.block-header h1 {
color: white;
}
my problem is that after translating up the image, the div that contains it remains unchanged, and has lots of white space in the place where the image used to be.
Hey you could try to use margins instead of transform, it's easier :
.image {
position: relative;
z-index: 10;
#media (min-width: 200px) {
img {
margin-top: -5em;
}
}
img {
width: 100%;
border: solid 1px black;
margin-left: 1em;
}
}
https://jsfiddle.net/49zcmf4z/4/
You can always "hardcode" the margins of the image (probably not best solution):
img {
width: 100%;
border: solid 1px black;
margin-left: 1em;
margin-bottom: -4em;}
https://jsfiddle.net/49zcmf4z/5/