how to make card deck and carousel overlapped - html

soo im trying to make a website that look like this
u can see theres a white background between my yellow background and my carousel. is there anyway to make the background behind my card deck not white instead the same color my carousel?
HTML
<div class="row-lg" id="backcolor">
<div class="card-deck mx-auto" id="card-deck">
<div class="card">
<img src="dummy.jpg" alt="dummy" class="card-img-top">
<div class="card-body" id="cardbody1">
<h5 class="card-title" id="cardtitle1">Card 1</h5>
<p class="card-text" id="cardtext1">Card text 1</p>
</div>
</div>
<div class="card">
<img src="dummy.jpg" alt="dummy" class="card-img-top">
<div class="card-body" id="cardbody2">
<h5 class="card-title" id="cardtitle2">Card 1</h5>
<p class="card-text" id="cardtext2">Card text 1</p>
</div>
</div>
<div class="card">
<img src="dummy.jpg" alt="dummy" class="card-img-top">
<div class="card-body" id="cardbody3">
<h5 class="card-title" id="cardtitle3">Card 1</h5>
<p class="card-text" id="cardtext3">Card text 1</p>
</div>
</div>
<div class="card">
<img src="dummy.jpg" alt="dummy" class="card-img-top">
<div class="card-body" id="cardbody4">
<h5 class="card-title" id="cardtitle4">Card 1</h5>
<p class="card-text" id="cardtext4">Card text 1</p>
</div>
</div>
<div class="card">
<img src="dummy.jpg" alt="dummy" class="card-img-top">
<div class="card-body" id="cardbody5">
<h5 class="card-title" id="cardtitle5">Card 1</h5>
<p class="card-text" id="cardtext5">Card text 1</p>
</div>
</div>
</div>
</div>
CSS
#card-deck {
padding-top: 190px;
height: 450px;
width: 1200px;
margin: 0 auto;
}
#card-deck .card {
padding-left: 20px;
padding-right: 20px;
max-width: 300px;
text-align: center;
}
#card-deck .card h5 {
color: orange;
}

Edit: We need to make your card container float over the two elements, because setting background-color to the card element, covers the background below it.
To do this, we need modify the #card-deck
position:relative so we could adjust its position according to its parent div
add top:30px; to position it 30px below its initial position
remove the height and padding properties as we're going to rely on the cards' height
add z-index:1 to position it over the other elements
Use this css for the #card-deck
#card-deck {
width: 1200px;
margin: 0 auto;
position:relative;
top:30px;
z-index:1;
}
Here's the updated fiddle;
https://jsfiddle.net/8y4ojb5t/

Its because you forgot # to background-color.
Your css:
#backcolor{
background-color: F1F0F0;
}
Use this:
#backcolor{
background-color: #F1F0F0;
}
Your image is cutting because of container-fluid 's padding left and right. So you have to remove that padding.
Try this css:
.container-fluid{
padding-left: 0;
padding-right: 0;
}

Related

Icon and Text Vertical alignment css

<div class="container-fluid" >
<section id="current-weather">
<div class="card text-center text-white bg-dark mb-3 " style="width: 60%;">
<div class="card-header">
weather
</div>
<div class="card-body">
<h2>{{location}}</h2>
<hr style="width: 30%;height: 2px; margin: 20px auto 20px auto;color: black;">
<h5 class="card-title"><i class="wi wi-owm-{{weather_current['weather'][0]['id']}}" style="font-size: 2.2em;"></i>{{weather_current['temp']}}°C</h5>
</div>
</div>
</section>
</div>
I have a problem with alignment text and icon. Look at screenshot
I've already tried to use vertical-align: middle and baseline. Maybe somebody can resolve my problem.
Here I have aligned it vertically and horizontally.
.container-fluid{
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
width: 60%;
}
<div class="container-fluid" >
<section id="current-weather">
<div class="card text-center text-white bg-dark mb-3">
<div class="card-header">
weather
</div>
<div class="card-body">
<h2>{{location}}</h2>
<hr style="width: 30%;height: 2px; margin: 20px auto 20px auto;color: black;">
<h5 class="card-title"><i class="wi wi-owm-{{weather_current['weather'][0]['id']}}" style="font-size: 2.2em;"></i>{{weather_current['temp']}}°C</h5>
</div>
</div>
</section>
</div>
Thanks and best regards!
I really appreciate your work, but I was asking to align icon and text in one line not the whole container on web page.
Check this image
Finally I coped with that. Here is my solution:
.align-inline {
display: flex;
align-items: center;
justify-content: center;
}
<div class="container-fluid" >
<section id="current-weather">
<div class="card text-center text-white bg-dark mb-3">
<div class="card-header">
weather
</div>
<div class="card-body">
<h2>{{location}}</h2>
<hr style="width: 30%;height: 2px; margin: 20px auto 20px auto;color: black;">
<h5 class="card-title align-inline"><i class="wi wi-owm-{{weather_current['weather'][0]['id']}}" style="font-size: 2.2em;"></i>{{weather_current['temp']}}°C</h5>
</div>
</div>
</section>
</div>
This is how result looks like

How to stack bootstrap cards from horizontally to vertical in order to make it responsive?

I am using Bootstrap to evenly align horizontally two cards, but I want to make it responsive so mobile users can see both cards stacked one above the other (in a column). So far I tried adding '''flex-direction''' with the #media tag to the '''justify-content-center''' tag. I also tried removing '''text-center''', '''object-fit: contain;''' and changing all types of '''display'''.
I am kind of new to front end. Appreciate any help.
CSS:
.separado{
display: inline-block;
*display: inline; /* For IE7 */
zoom: 1; /* Trigger hasLayout */
width: 45%;
text-align: center;
margin-right: 5%;
margin-left: 5%;
margin-bottom: 3%;
}
.imagen_top3{
object-fit: contain;
max-height: 600px;
border: 5px solid #252727;
padding: 1px;
}
#media screen and (max-width: 980px) {
.list-images img {
width: 100%;
margin: 3%;
flex-direction: column;
}
.separado{
zoom: 1; /* Trigger hasLayout */
width: 100%;
text-align: center;
margin: 3%;
flex-direction: column;
}
}
HTML:
<div class="d-flex justify-content-center text-center">
<div class="card text-center separado" style="width: 40%; background-color: #252727;">
<img class="card-img-top imagen_top3" src="image1.jpeg" alt="Card image cap">
<div class="card-body">
<p class="card-text" style="color:whitesmoke">Hi im John</p>
</div>
</div>
<div class="card text-center separado" style="width: 40%;background-color: #252727;">
<img class="card-img-top imagen_top3" src="image2.jpeg" alt="Card image cap">
<div class="card-body">
<p class="card-text" style="color:whitesmoke">Hi im Peter</p>
</div>
</div>
</div>
There is no need for CSS, just use the bootstrap inbuilt grid;
<div class="row">
<div class="col-xxl-6 col-md-12">
<div class="card text-center">
<img class="card-img-top" src="https://source.unsplash.com/ewqfhcrLoYA" alt="Card image cap">
<div class="card-body">
<p class="card-text" style="color:whitesmoke">Hi im John</p>
</div>
</div>
</div>
<div class="col-xxl-6 col-md-12">
<div class="card text-center">
<img class="card-img-top" src="https://source.unsplash.com/Edz4CIdzpA8" alt="Card image cap">
<div class="card-body">
<p class="card-text" style="color:whitesmoke">Hi im Peter</p>
</div>
</div>
</div>
</div>
Remove all the CSS you provided except with the one for styling purpose.
Codepen: https://codepen.io/manaskhandelwal1/pen/rNMqYag

Image spanning to the next div when window size is decreased

So, I have to create this Page where in you get text alongside image displayed as seen in here
But , on minimising the window size the image gets overlapped as seen here
<div class="header1">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="pull-right img1">
</div>
</div>
and Here is the css
.hedtext {
padding-top:10px;
margin-bottom: -19px;
line-height: 2pt;
font-size: 13px;
font-weight: 750;
float: left;
}
.header1 {
border: 1px solid black;
height: 150px;
}
.img1 {
width: auto;
height: 130px;
padding :10px;
}
Also, using bootstrap 3 . All i want is that the image goes side by side the text on minimising the window size .
First you have forgot to add the .row class div which bootstrap requires to wrap around the columns to work correctly.
I removed .pull-right and instead just added text-right to the column. You can also use floats though or whatever to set the image to the right side however you wish.
<div class="header1 row">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4 text-right">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
class="img1">
</div>
</div>
You have to wrap col in row
Remove the .hedtext - float (bootstrap worry about float)
Remove .header1 height: 130px; (It the reason image out of border)
See working code
.hedtext {
line-height: 2pt;
font-size: 13px;
font-weight: 750;
}
.row {
border: 1px solid black;
}
.img1 {
width: auto;
height: 130px;
padding: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-8">
<h4 class="hedtext">Name</h4>
<h4 class="hedtext">Address</h4>
<h4 class="hedtext">Contact Number</h4>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="img1">
</div>
</div>
</div>
you have to add responsive class in div like col-xs-* for responsive
do this for your solution
<div clss="row">
<div class="header1">
<div class="col-md-8 col-xs-8">
<h4 class="hedtext">Name</h4>
</br>
<h4 class="hedtext">Address</h4>
</br>
<h4 class="hedtext">Contact Number</h4>
</br>
<h4 class="hedtext">Fax</h4>
</div>
<div class="col-md-4 col-xs-4">
<img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
class="pull-right img1">
</div>
</div>
</div>

How to make responsive cards as shown below?

I am having some problem with that black box with date. I made it but it isn't responsive.
.date
{
width: 20%;
height: 15%;
background-color: black;
z-index: 1;
position: absolute;
top: 45%;
left: 8%;
}
<div class="card up" style="width:400px height:400px">
<img class="card-img-top" src="https://placehold.it/1900x1400" alt="Card image" style="width:100%">
<div class="date">
</div>
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text some example text. John Doe is an architect and engineer</p>
See Profile
</div>
</div>
Use position-absolute for the card-body
Put the date inside the card-body and give it negative top value.
Fixed size
.date {
width: 50px;
height: 50px;
background-color: black;
top: -25px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-6 mx-auto ">
<div class="card up" style="width:400px height:400px">
<img class="card-img-top" src="https://placehold.it/1900x1400" alt="Card image" style="width:100%">
<div class="card-body position-relative pt-5">
<div class="date position-absolute"></div>
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text some example text. John Doe is an architect and engineer</p>
See Profile
</div>
</div>
</div>
</div>
</div>
Relative size
.date {
width: 3.8888888889em;
height: 3.8888888889em;
background-color: black;
top: -1.9em;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-6 mx-auto ">
<div class="card up" style="width:400px height:400px">
<img class="card-img-top" src="https://placehold.it/1900x1400" alt="Card image" style="width:100%">
<div class="card-body position-relative pt-5">
<div class="date position-absolute"></div>
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text some example text. John Doe is an architect and engineer</p>
See Profile
</div>
</div>
</div>
</div>
</div>
https://codepen.io/anon/pen/gKzQez
https://css-tricks.com/almanac/properties/p/position/
You can also do this with negative margin too.
First you have to respecify the width and height of 'card' and 'up' classes (missing semicolumn).
Then with the actual code snippet i can't clearly see what is wrong, but if you have responsive problem with absolute positioning, try to add "position: relative" to your container so the absolute elements won't overflow their parent block.
Lets understand the issue of this case first. As you have added width: 100% to the image, this has a responsive height. Therefore, .card doesn't have a fix height. When you use top: 40% (percentage value), this breaks the view.
Solution;
wrap image and .date inside another div.
<div style="position: relative;">
<img class="card-img-top" src="https://placehold.it/1900x1400" style="width: 100%;" alt="Card image">
<div class="date"></div>
</div>
And, set bottom: - 20% or appropreate value instead of top: 40% for .date class.
Hope this will fix the issue.

CSS: How to get this effect ? (Picture on top of a card, going outside it)

I'm fairly new to CSS, so I apologize if someone asked for this effect before, I don't know the name of it.
I need to create this (picture 1), I currently have this (picture 2):
I don't know hot to create this effect or what is the name of it.
I have tried playing with z-index and padding, but I don't think that this is the best solution.
Here is the code (for the picture 2):
<div class="row text-center">
<div class="col-lg-4">
<div class="card" style="width: 20rem;">
<img class="card-img-top" src="picture.png" alt="Card image cap">
<div class="card-block">
<h4 class="card-title">Mirion Jones</h4>
<p class="card-position">CEO Founder</p>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
</div>
I am using Bootstrap 4.
Hope the code below helps. I set the image size to 60px by 60px, and set the margin and top accordingly, you should change them with your desired dimension.
.card-img-top {
position: absolute;
top: -30px;
left: 50%;
margin-left: -30px;
width: 60px !important;
height: 60px;
}
.card {
margin-top: 30px;
padding-top: 30px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<div class="row text-center">
<div class="col-lg-4">
<div class="card" style="width: 20rem;">
<img class="card-img-top img-circle rounded-circle" src="https://dummyimage.com/100x100/000/fff" alt="Card image cap">
<div class="card-block">
<h4 class="card-title">Mirion Jones</h4>
<p class="card-position">CEO Founder</p>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
</div>