CSS transform scale increase also div parent body - html

I have a problem in formatting an anchor link using the transform scale attributes when hovering on it.
I have a link inside a div (that div is used to alight the link to the right), and i would like to enlarge when I hover on it. However, when i do it, it also increase the body size of the parent div, thus moving all my other elements on the page. Why that happens? As far as I know scale should not act on the size of the elements, least of all on its parent.
Can you tell me where I'm wrong. I'm quite new to html and css, so maybe i completely set up bad my code.
Thanks to anyone who can help me.
a#fonte1 {
font-size: 1rem !important;
font-weight: 300 !important;
transition: transform 0.2s ease !important;
display: inline-block !important;
}
a#fonte1:hover {
transform: scale(1.2) !important;
cursor: pointer !important;
color: rgb(13,89,253) !important;
border: 1px solid rgb(13,89,253) !important;
border-radius: 0.3rem !important;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<section class="showcase border-bottom">
<div class="container-fluid p-0">
<div class="row g-0">
<div class="col-lg-6 order-lg-2">
...
</div>
<div class="col-lg-6 order-lg-1 ">
<h2>[title 1]</h2>
<p class="mb-0" style = "text-align: justify">
...
</p>
<div style="text-align:right;">
<a id="fonte1" href="#">
Link
</a>
</div>
</div>
</div>
<div class="row g-0">
<div class="col-lg-6 ">
...
</div>
<div class="col-lg-6 ">
<h2>[title 2]</h2>
<p class="mb-0" style = "text-align: justify">
...
</p>
</div>
</div>
</div>
</section>

You are adding a border on hover which changes the size of the element. Add a transparent border on the base state and change its color on hover.
a#fonte1 {
font-size: 1rem;
font-weight: 300;
transition: transform 0.2s ease;
display: inline-block;
border: 1px solid transparent;
}
a#fonte1:hover {
transform: scale(1.2);
cursor: pointer;
color: rgb(13, 89, 253);
border: 1px solid rgb(13, 89, 253);
border-radius: 0.3rem;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<section class="showcase border-bottom">
<div class="container-fluid p-0">
<div class="row g-0">
<div class="col-lg-6 order-lg-2">
...
</div>
<div class="col-lg-6 order-lg-1 ">
<h2>[title 1]</h2>
<p class="mb-0" style="text-align: justify">
...
</p>
<div style="text-align:right;">
<a id="fonte1" href="#">
Link
</a>
</div>
</div>
</div>
<div class="row g-0">
<div class="col-lg-6 ">
...
</div>
<div class="col-lg-6 ">
<h2>[title 2]</h2>
<p class="mb-0" style="text-align: justify">
...
</p>
</div>
</div>
</div>
</section>

Related

Change background-color/background-image of div on hover of each cards

I have three different cards, I want to change the background color respective the card I hover on. I have tried .card-2:hover #landing {background-color: blue;} but that doesn't work. I want the entire body's background-color changed. Like here https://imgur.com/a/xEBiRIo
Landing screen
<div id="landing">
<div class="container d-flex justify-content-end align-items-center" style="height: 100vh !important;">
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card card-1 h-100">
<div class="card-body">
<h5 class="card-title">Purple</h5>
<p class="card-text">Hover over me to see purple bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-2 h-100">
<div class="card-body">
<h5 class="card-title">Blue</h5>
<p class="card-text">Hover over me to see blue bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-3 h-100">
<div class="card-body">
<h5 class="card-title">Red</h5>
<p class="card-text">Hover over me to see red bg</p>
</div>
</div>
</div>
</div>
</div>
</div>
#landing {
background-color: #202140;
height: 100vh;
}
.card, .list-group-item {
border-radius: 0px !important;
font-family: 'text-main' !important;
color: white !important;
text-shadow: rgba(0, 0, 0, 0.336) 0px 0 10px;
background-color: rgba(32, 33, 64, 0) !important;
-webkit-backdrop-filter: blur(100px) !important;
backdrop-filter: blur(100px) !important;
}
I am using bootstrap v5.2 and jquery 3.6.0
There's two issues here. The first problem is your selector. .card-2:hover #landing is looking for a #landing element inside .card-2 - this should be the other way around.
The second problem is due to your use of !important the :hover rule isn't specific enough to override the default styling. Remove the !important flag, and strongly consider never using them again. They are a code smell indicative of a poorly thought through CSS pattern. If you need to override an inherited style, use a more specific selector instead.
With those issues addressed, the code works:
#landing {
background-color: #202140;
height: 100vh;
}
#landing .card,
.list-group-item {
border-radius: 0px;
font-family: 'text-main';
color: white;
text-shadow: rgba(0, 0, 0, 0.336) 0px 0 10px;
background-color: rgba(32, 33, 64, 0);
-webkit-backdrop-filter: blur(100px);
backdrop-filter: blur(100px);
}
#landing .card-1:hover {
color: purple;
}
#landing .card-2:hover {
color: blue;
}
#landing .card-3:hover {
color: red;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div id="landing">
<div class="container d-flex justify-content-end align-items-center" style="height: 100vh !important;">
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card card-1 h-100">
<div class="card-body">
<h5 class="card-title">Purple</h5>
<p class="card-text">Hover over me to see purple bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-2 h-100">
<div class="card-body">
<h5 class="card-title">Blue</h5>
<p class="card-text">Hover over me to see blue bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-3 h-100">
<div class="card-body">
<h5 class="card-title">Red</h5>
<p class="card-text">Hover over me to see red bg</p>
</div>
</div>
</div>
</div>
</div>
</div>
-- Update --
Following the clarification in the comments that you want to set the background-color of #landing when hovering the .card elements, then this needs to be done in JS. This is because #landing is a parent element of the .card, and CSS selectors cannot affect parent elements.
To do this you can use jQuery to update the parent #landing when the .card is hovered. Note that I made this function DRY by using the common .card class as the selector and storing the colour to be set on #landing in the data of each element:
let $landing = $('#landing');
$('.card').hover(
e => $landing.css('background-color', $(e.currentTarget).data('color')),
e => $landing.css('background-color', $landing.data('default-color'))
)
#landing {
background-color: #202140;
height: 100vh;
}
#landing .card,
.list-group-item {
border-radius: 0px;
font-family: 'text-main';
color: white;
text-shadow: rgba(0, 0, 0, 0.336) 0px 0 10px;
background-color: rgba(32, 33, 64, 0);
-webkit-backdrop-filter: blur(100px);
backdrop-filter: blur(100px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div id="landing" data-default-color="#202140">
<div class="container d-flex justify-content-end align-items-center" style="height: 100vh !important;">
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card card-1 h-100" data-color="purple">
<div class="card-body">
<h5 class="card-title">Purple</h5>
<p class="card-text">Hover over me to see purple bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-2 h-100" data-color="blue">
<div class="card-body">
<h5 class="card-title">Blue</h5>
<p class="card-text">Hover over me to see blue bg</p>
</div>
</div>
</div>
<div class="col">
<div class="card card-3 h-100" data-color="red">
<div class="card-body">
<h5 class="card-title">Red</h5>
<p class="card-text">Hover over me to see red bg</p>
</div>
</div>
</div>
</div>
</div>
</div>

bootstrap 4 element positioning in Angular application view

I'm working on an Angular 7 blog application where I'm having some difficulty in adjusting the view of a template made with bootstrap 4. In the main HTML component, I've created two cards in a row, one of it is the blog posts and the other card contains category. The category card is getting fetched from a different component and called using it's selector i.e <app-blog-category></app-blog-category> in the main HTML component. Below are the problems I'm facing in the view. Please look at the image below for reference. Also you can view it from this link ---> https://stackblitz.com/edit/angular-tlbxbr?file=src%2Fapp%2Fapp.component.html
1) The category card is getting rendered beside the last blog document thus leaving a significant amount of space on the top. If I apply style margin-top:negetive-value on the card class as style it is getting resolved but then again the value is differing as the device-width increases or decreases and it goes way above or below than what is needed.
2) the image inside the horizontal card is not taking the full height and width of the card
3) When the device-width is between than 768px-991px, the category card elements i.e the header and list items are breaking maybe due to too much padding around them or being centered.
HTML:
<div class="container">
<div class="row col col-md-12 mx-auto" style="text-align:center; font-size:22px">All Blogs
<br><br><br><br>
</div>
<div class="row" *ngIf="allBlogs.length>0">
<div class="col-md-9 card" *ngFor="let blog of allBlogs">
<div class="row">
<div class="col-md-4">
<a [routerLink]="['/blog', blog.blogId]"><img src="http://localhost:4000/{{blog.imagePath}}" class="card-img-top card-img-size" alt="blog1"></a>
</div>
<div class="col-md-8 px-3">
<div class="card-block px-3">
<h4 class="card-title">{{blog.title}}</h4>
<p class="card-text">{{blog.description}}</p>
<br>
<a [routerLink]="['/blog', blog.blogId]" class="mt-auto btn btn-primary">Read More</a>
</div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="container"> //note that this part is called from a separate angular component by it's selector <app-blog-category></app-blog-category>
<div class="row">
<div class="col-md-12 card">
<article class="filter-group">
<div class="card-body">
<header class="card-header">
<h6 class="title">Categories</h6>
</header>
<ul class="list-menu">
<li *ngFor="let category of categories" [routerLink]="['/bycategory/', category.categoryId]">{{category.categoryName}}</li>
</ul>
</div>
</article>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
.card-block {
font-size: 1em;
position: relative;
margin: 0;
padding: 1em;
border: none;
border-top: 1px solid rgba(34, 36, 38, .1);
box-shadow: none;
}
.card {
font-size: 1em;
overflow: hidden;
padding: 5;
border: none;
border-radius: .28571429rem;
box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
margin-top:20px;
}
.btn {
margin-top: auto;
}
.filter-group {
border-bottom: 1px solid #e4e4e4
}
.card-header {
padding: 0.75rem 1.25rem;
margin-bottom: 0;
background-color: #fff;
border-bottom: 1px solid rgba(0, 0, 0, 0.1)
}
.filter-group .card-header {
border-bottom: 0
}
.icon-control {
margin-top: 6px;
float: right;
font-size: 80%
}
.list-menu {
list-style: none;
margin: 0;
padding-left: 0
}
.list-menu a {
color: #343a40
}
a {
text-decoration: none !important;
background-color: transparent
}
I hope this works for you :
<div class="container">
<div class="row col col-md-12 mx-auto" style="text-align:center; font-size:22px">All Blogs
<br>
<br>
<br>
<br>
</div>
<div class="row">
<div class="col-12 col-md-9 order-2 order-md-1">
<div class="row" *ngIf="allBlogs.length>0">
<div class="col-md-12 card" *ngFor="let blog of allBlogs">
<div class="row">
<div class="col-md-4 p-0">
<a href="#">
<div class="card-img-top card-img-size" style="height: 100%; background-image: url('https://images.pexels.com/photos/1804035/pexels-photo-1804035.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500'); background-size: cover; background-position: center;" alt="blog1"></div>
</a>
</div>
<div class="col-md-8 px-3">
<div class="card-block px-3">
<h4 class="card-title">{{blog.title}}</h4>
<p class="card-text">{{blog.description}}</p>
<br>
Read More
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-3 order-1 order-md-2" style="margin-top: 1.1%;">
<app-blog-category></app-blog-category>
</div>
</div>
</div>

Bootstrap 4 - content sticking to the bottom of div when making it square

I am working on a budgeting app, and I am trying to make something that looks like a bunch of tiles (below). However I am getting stuck, because when I go to put content in the tiles, the content sticks to the bottom.
I am using bootstrap 4, and I have been able to make some square divs, and style them to my liking (thanks SO), but I just can't add anything to them. How would I solve this?
(also on a related/unrelated note when I put m-2 on the divs it bumps the rightmost div down a row)
.squareBox:before{
padding-top: 100%;
/* makes expand to a square */
content: '';
width: 0;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>
What it currently looks like:
What it needs to look like:
I would use a different method to make the boxes square. Use a margin "dummy" div, and place the squareBox inside the columns...
.dummy {
margin-top: 100%;
}
.squareBox {
background: #1A3967;
color: #fff;
border-radius: 10px;
position: absolute;
top: 30px;
bottom: 0;
left: 30px;
right: 0;
}
Then you can put whatever is needed inside each box, using Bootstrap 4 flexbox utils to position it.
Demo: https://www.codeply.com/go/MZrc2ELjIG
You could try the flexbox approach :)
.squareBox{
/* makes expand to a square */
width: 200px;
height: 200px;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
max-width: 200px;
}
.justify-start {
align-self: flex-start !important;
}
.t-1 {
font-size: 1.2rem;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="m-5 d-flex justify-content-center align-items-center">
<div class="squareBox icon d-flex flex-column justify-content-between align-items-center m-2">
<div class="d-flex align-self-start justify-content-between w-100 p-2">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
<p class="font-weight-bold text-muted">$XX.X</p>
</div>
<div class="d-flex justify-content-center align-items-center text-white text-center">
<p class="font-weight-bold t-1">Netflix & Hulu With roommcomm</p>
</div>
<div class="d-flex align-self-start justify-content-around w-100 text-white">
<p>Sorted</p>
<p>3</p>
</div>
</div>
<div class="squareBox icon d-flex flex-column justify-content-between align-items-center m-2">
<div class="d-flex align-self-start justify-content-between w-100 p-2">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
<p class="font-weight-bold text-muted">$XX.X</p>
</div>
<div class="d-flex justify-content-center align-items-center text-white text-center">
<p class="font-weight-bold t-1">End of The F****** World</p>
</div>
<div class="d-flex align-self-start justify-content-around w-100 text-white">
<p>Sorted</p>
<p>5</p>
</div>
</div>
</div>
also, here's a working example :)
On a side note, I modified your squareBox class's width and height to give it dimensions :)
On the other hand, you can apply the flex-wrap class on the parent container so the stuff inside it that doesn't fit in a given row will go to the next row instead
You would want to set the icon to absolute and set to top with a bit of left and top offset.
If you're not gonna make these 'icon'-looking-things as image. then you have to rely heavily on absolute positioning.
.squareBox:before {
padding-top: 100%;
/* makes expand to a square */
content: '';
width: 0;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.icon .row {
position: absolute;
top: 5px;
left: 20px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>
Rather than using padding-top: 100%; to define the dimensions of square box
, add height and width.
.squareBox{
width: 100px;
height: 100px;
padding: 5px;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>

Page content overlapping navbar

I am having some trouble with some of my bootstrap cards overlapping my navbar. I made sure that none of my positions were absolute and that the z indexes were handled properly, but I still get the same issue. doing padding-top on the body did not give me the result I wanted either. Here are some before and after pictures.
#top {
top: 0;
position: fixed;
z-index: 1;
}
.topbar {
height: 90px;
background-color: #24414e;
border-left: 2px solid #24414e;
border-right: 2px solid #24414e;
border-top: 2px solid #24414e;
border-bottom: 2px solid #24414e;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
animation-name: greeting;
animation-duration: 8s;
animation-delay: 1s;
}
#keyframes greeting {
0% {
background: url('https://cdn.dribbble.com/users/751466/screenshots/3360272/hello-3.gif');
background-size: 100% 100%;
}
60% {
opacity: 1;
}
}
/*
.topbar:hover{
background:url('https://cdn.dribbble.com/users/751466/screenshots/3360272/hello-3.gif');
background-size: 100% 100%;
}
*/
.logo {
transform: translateY(50%);
font-family: "Dancing Script";
color: #ffffff;
}
.holder {
width: 5%;
height: 80%;
margin-right: 30px;
margin-top: 10px;
}
.out {
margin-top: 46px;
color: #ffffff;
margin-right: 0;
}
.out:hover {
text-decoration: underline;
}
.menu {
height: 15%;
margin-top: 0px;
background-color: #f7ce3e;
}
/*
.iconbar{
margin-top: 20px;
margin-right: 20px;
margin-left:20px;
height =
text-align: center;
border-left: 2px solid #24414e;
border-right: 2px solid #24414e;
border-top: 2px solid #24414e;
border-bottom: 2px solid #24414e;
}
*/
.icon {
margin-top: 10px;
color: #24414e;
animation-name: iconSlide;
animation-duration: 1s;
}
.txt {
font-size: 15px;
visibility: hidden;
margin-top: 0px;
color: #24414e;
}
#keyframes iconSlide {
0% {
transform: translateX(600%);
}
100% {
transform: translateX(0);
}
}
.icon-1:hover~.txt-1 {
visibility: visible;
}
.icon-2:hover~.txt-2 {
visibility: visible;
}
.icon-3:hover~.txt-3 {
visibility: visible;
}
.icon-4:hover~.txt-4 {
visibility: visible;
}
.icon-5:hover~.txt-5 {
visibility: visible;
}
.icon-6:hover~.txt-6 {
visibility: visible;
}
.icon:hover {
color: #ffffff;
}
.rest {
height: 100%;
}
.contacts {
position: relative;
z-index: -1;
}
<!DOCTYPE html>
<html lang="en">
<!---This is for importing bootstrap and the CSS File--->
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="templatestyle.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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>
<link href='https://fonts.googleapis.com/css?family=Dancing Script' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!---Nav Bar and Header--->
<section id="top">
<!---Header--->
<div class="container-fluid topbar">
<h1 class="float-left logo">Example</h1>
<h5 class="float-right out">log out</h5>
<img src="blank-person-male.png" alt="profilepic" class="rounded-circle float-right holder"></img>
</div>
<!---Nav Bar--->
<div class="container-fluid menu" id="openMenu">
<div class="row">
<div class="col-2 text-center">
<i class="fa fa-tachometer fa-2x icon icon-1" aria-hidden="true"></i>
<h5 class="txt txt-1">Dashboard</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-user fa-2x icon icon-2" aria-hidden="true"></i>
<h5 class="txt txt-2">Profile</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-certificate fa-2x icon icon-3" aria-hidden="true"></i>
<h5 class="txt txt-3">Certificates</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-paper-plane fa-2x icon icon-4" aria-hidden="true"></i>
<h5 class="txt txt-4">Send/Apply</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-cog fa-2x icon icon-5" aria-hidden="true"></i>
<h5 class="txt txt-5">Settings</h5>
</div>
<div class="col-2 text-center">
<i class="fa fa-envelope fa-2x icon icon-6" aria-hidden="true"></i>
<h5 class="txt txt-6">Messages</h5>
</div>
</div>
</div>
</section>
<section class="rest container-fluid">
<h2 class="text-center"><u>Dashboard</u></h2>
<!---Contacts--->
<h4>Online contacts:</h4>
<div class="row contacts">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 1</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 2</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 3</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 4</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 5</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 6</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card border-success">
<div class="card-header">Person 7</div>
<div class="card-body">
<img src="blank-person-male.png" alt="profilepic" class="card-img-top rounded"></img>
</div>
<div class="card-footer">
<button type="Button" class="bg-primary rounded mx-auto .text-light">Send Chat</button>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
This is a simple fix, just set your Header z-index: 2; and your cards z-index: 1;.
I didn't really go over your code but setting the header an higher z-index as the content for sure will fix it.
The answer is you have given position:fixed to the header(.top) to fix it at the top with top:0, so you must need to give margin-top to the section next to it containing classes class="rest container-fluid" otherwise it will overlap as it seems with absolute positioned element.
Setting margin:top:159px fix the issue.
Please note that 159px is top header's height here. Happy coding :)
Use the fixed-top class instead of the top CSS code. And add 160px padding-top for the body.
/*
The headers height is 159.5px
*/
body {
padding-top: 160px;
}
fixed-top removes the element that you use it for, from the normal flow of the content, and, hence, the element will overlay the other content
To fix the issue, you need to push down the main content equal or larger than the height of the fixed-top element. You can do so by setting the padding-top of the body equal or larger than the fixed-top element's height. For example, if the fixed-top element's height is 72px, padding-top of body should be, at least, 72px. If you wish, you can use relative units: padding-top: 4.5rem; instead of padding-top: 72px;.
body {
padding-top: 72px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="fixed-top bg-light">
<div>
<noscript>
<h1 style="color:#FF0000;">
This reportFile will not be navigable without Javascript, please enabled Javascript
</h1>
</noscript>
<img srcset="style/songkongheader.png 400w,style/songkongheader-medium.png 200w,style/songkongheader-small.png 100w," sizes="(max-width:800px) 200px,(max-width:600px) 100px,400px" class="mb-2">
</div>
<header>
<h2 class="subheading" title="Start Fixing Songs">
<a class="mx-2">
Fix Songs
</a>
</h2>
</header>
</div>
<main class="container-fluid bg-primary bd-">
<div class="row">
<div class="col py-5">Hello</div>
</div>
</main>
This is what both bootstrap-3 and bootstrap-4 has done. I recommend you to inspect it yourself.
You may find these two link useful.
w3schools - How to - fixed menu
teamtreehouse - div hiddne below fixed position navbar
A codepen of your work

Zoom in image while text is overlapping it (in the image)

Okay so I have this:
I want to add pictures in the Recommend 1, Recommend 2 ... I have achieved this using the <img> tag. But I have two problems:
1) It will not fit the square, it just sets the height and width of the image. (See this image: https://imgur.com/a/Hkm6ZRy )
2) I need the text to be on the bottom of the image / container (just like it is right now.) I tried fixing this with position: absolute;, but I got this - https://imgur.com/a/9OdDF1I . The image is top right for some reason.
I'm not using css background image because I need the zoom effect when the user hover over the picture.
Here is the HTML (for the 4 recommend elements):
<div class="col-xl-9 col-md-9 sec-three-right bg-primary">
<div class="container-fluid h-100">
<div class="row h-100 text-center">
<div class="col-xl-6 d-flex flex-column zoom">
<img class="img-fluid" src="img/pickone.jpeg" alt="pickone" style="width:100%;">
<div class="mt-auto right-pick">Recommend 1</div>
</div>
<div class="col-xl-6 bg-success d-flex flex-column">
<div class="mt-auto right-pick"> Recommend 2 </div>
</div>
<div class="col-xl-6 bg-danger d-flex flex-column">
<div class="mt-auto right-pick"> Recommend 3 </div>
</div>
<div class="col-xl-6 bg-info d-flex flex-column">
<div class="mt-auto right-pick"> Recommend 4 </div>
</div>
</div>
</div>
Here is the CSS:
.sec-three-left {
padding-left: 0;
padding-right: 0;
}
.sec-three-right {
padding-left: 0;
padding-right: 0;
}
.right-pick {
margin-bottom: 25px;
font-size: 25px;
letter-spacing: 0.8px;
color: white;
text-shadow: 2.5px 2.5px black;
}
.zoom {
position: relative;
overflow: hidden;
}
.zoom:hover img {
transform: scale(1.1);
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
}
.zoom img {
transition: all 0.4s;
-moz-transform: all 0.4s;
-webkit-transform: all 0.4s;
}
Here is the JSFiddle: https://jsfiddle.net/prozik/jvneLe9e/
I want it to look like this:
I'm using Bootstrap v4.1.0 and jQuery 3.3.1.
Fixed my problem with position: absolute;:
Here is the HTML:
<div class="col-xl-9 col-md-9 sec-three-right">
<div class="container-fluid h-100">
<div class="row h-100 text-center">
<div class="col-xl-6 d-flex flex-column zoom">
<img class="img-fluid" src="img/pickone.jpeg" alt="pickone">
<div class="mt-auto right-pick">Recommend 1</div>
</div>
<div class="col-xl-6 d-flex flex-column zoom">
<img class="img-fluid" src="img/pickone.jpeg" alt="pickone">
<div class="mt-auto right-pick"> Recommend 2 </div>
</div>
<div class="col-xl-6 d-flex flex-column zoom">
<img class="img-fluid" src="img/pickone.jpeg" alt="pickone">
<div class="mt-auto right-pick"> Recommend 3 </div>
</div>
<div class="col-xl-6 d-flex flex-column zoom">
<img class="img-fluid" src="img/pickone.jpeg" alt="pickone">
<div class="mt-auto right-pick"> Recommend 4 </div>
</div>
</div>
</div>
</div>
And the CSS:
.right-pick {
position: absolute;
font-size: 25px;
letter-spacing: 0.8px;
color: white;
text-shadow: 2.5px 2.5px black;
bottom: 15px;
text-align: center;
width: 100%;
}
This is the result:
I have fixed it. You also have to remove default padding from the .col classes.
.right-pick {
position:absolute;
bottom :20px;
left: 50%;
transform: translateX(-50%);
font-size: 25px;
letter-spacing: 0.8px;
color: white;
text-shadow: 2.5px 2.5px black;
}
Fixed Code :-
https://jsfiddle.net/jvneLe9e/1/