'How do i center this columns with the content floating to the left?
I would like the two col's to be centered if I have a window larger than 1024pix width and be responsive. I've tried a few things, but unfortunately I'm no longer sure how to do it the easiest and cleanest way.
here is the whole code:
<style type="text/css">
body {
margin: 30px;
}
.my-container {
border: 1 px solid green;
}
.my-row {
border: 1px solid red;
}
.my-col {
border: 3px dotted blue;
}
.sidebar {
margin: 0;
padding: 0;
text-align: left;
width: 100%;
background-color: transparent;
position: fixed;
height: 100%;
overflow: auto;
list-style-type: none;
font-size: 14px !important;
}
.sidebar a {
display: block;
color: #666666;
padding: 8px;
text-decoration: none;
list-style-type: none;
}
.sidebar li {
list-style: none;
text-decoration: none;
}
.sidebar a.active {
background-color: transparent;
color: #4d4d4d;
list-style-type: none;
}
.sidebar a:hover:not(.active) {
background-color: transparent;
color: rgb(49, 49, 49);
}
@media screen and (min-width: 768px) {
.d-xl-none{display: none; }}
@media screen and (max-width: 768px) {
div.content {margin-left: 0;}
div.preview {margin-left: 0;}
.sidebar {height: 100%;position: relative;text-align: center;margin-bottom: 0px !important;display: none; }
.sidebar a {float: left;align-items: center; }
.caption {text-align: center !important; }
.containerCarousel {margin-top: 0px;margin-bottom: 150px;width: 1fr;} }
.overlay {height: 100%;width: 0;position: fixed;z-index: 1;top: 0;left: 0;background-color: rgb(0, 0, 0);background-color: rgba(0, 0, 0, 0.9);overflow-x: hidden;transition: 0.5s;}
.overlay-content {position: relative;top: 10%;width: 100%;text-align: center;margin-top: 30px;}
.overlay a {padding: 8px;text-decoration: none;font-size: 15px;color: #818181;display: block;transition: 0.3s;}
.overlay a:hover,
.overlay a:focus {color: #f1f1f1;}
.overlay .closebtn {position: absolute;top: 20px; right: 45px; font-size: 40px;}
@media screen and (max-height: 480px) {
.overlay a {font-size: 20px }
.overlay .closebtn {font-size: 20px;top: 15px; right: 35px;}
.sidebar a {text-align: center;float: none;}
.sidebar {display: none; }
.content { margin-top: 10px !important;}
.preview { margin-top: 10px !important; }
.caption {text-align: center !important; }
}
</style>
<!doctype html>
<html lang="en">
<head>
<title>Christoph Urwalek</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<!-- START Mobile Nav-->
<div id="myNav" class="overlay">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<div class="overlay-content">
<a href="./painting.html">painting</a>
<a href="./drawing.html">drawing</a>
<a href="#">collage</a>
<a href="#">video</a>
<a href="#">current</a>
<a href="#">text</a>
<a href="#">biography</a>
<a href="#">contact</a>
</div>
</div>
<!-- END Mobile Nav-->
<span class="d-xl-none" style="font-size:30px;cursor:pointer; color: #4d4d4d;" onclick="openNav()">☰ <font size="-1"><b>Christoph Urwalek</b></font></span>
<!--START Wrapper-->
<div class="container-fluid my-container align-items-center">
<!--START Sidebar -->
<div class="row my-row">
<div class="col-md-3 ">
<nav class="sidebar-header sidebar">
<li><a class="active" href="./index.html"><b>Christoph Urwalek</b></a></li>
<li><a href="./painting.html">painting</a></li>
<li><a href="./drawing.html">drawing</a></li>
<li><a href="#">collage</a></li>
<li><a href="#">video</a></li>
<li><a> </a></li>
<li><a href="#">current</a></li>
<li><a href="#">text</a></li>
<li><a href="#">biography</a></li>
<li><a href="#">contact</a></li>
</nav>
</div>
<!--END Sidebar -->
<!--START Wandcollage-->
<div class="col-md-9 ">
<img id="LP_img" src="http://christophurwalek.at/index/Wandcollage.jpg" class="img-fluid"
alt="Responsive image">
</div>
</div>
</div>
<!--END Wrapper-->
<script type="">
function openNav() {
document.getElementById("myNav").style.width = "100%";
}
function closeNav() {
document.getElementById("myNav").style.width = "0%";
}
</script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<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.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
</body>
</html>
If you notice errors I would be very grateful for a correction.
Thanks in advance,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|