My latest project involved creating a simple HTML code using HTML, CSS, and Bootstrap. I utilized col-md-4
and col-md-8
to divide a row. However, I noticed that the background image from col-md-8
gets shifted down when I resize the window.
Below, I have provided snippets from the HTML and CSS files for reference:
<html>
<head>
<title> Bootstrap Practice </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="tp.css" rel="stylesheet" type="text/css"/>
</head>
<body background = "red">
<div class = "container-fluid">
<div class = "row" >
<div class="col-md-4 col-sx-4 col-lg-4 nopadding" style="height:100%; ">
<p style="align:middle"> This is first column bg </p>
</div>
<div class="col-md-8 col-sx-8 col-lg-8 shutterstock_227863141 nopadding" style="height:100%; ">
<p> This is second column </p>
</div>
</div>
</div>
</body>
</html>
CSS File:
.shutterstock_227863141{
width: 60%;
height: 500px;
background-image: url(Learning_fun.jpg);
background-repeat: no-repeat;
background-size: cover;
background-color: #464646;
}
.nopadding{
margin : 0 !important;
padding : 0 !important;
}
I am currently looking for a solution to prevent the background image in col-md-8
from shifting down. Any advice or guidance would be greatly appreciated.