So basically I am having trouble centering my images and I wanted to know what I could take away or add to center them. I have been having difficulty as I use justify center and other properties as well. My first image is stuff to the end f my page and I want to move it over just a little so it’s away from the margin line and my header is also covering my middle image. So basically I want to know how I can fix this issue as I try to finish my about me page thanks.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Personal Project</title>
<!-- bootstrap and aos -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/aos.css">
<!-- css -->
<link rel="stylesheet" href="assets/css/style.css">
<!-- https://github.com/SA7MAN/brooklyn-complete -->
</head>
<body>
<nav class="navbar sticky-top navbar-expand-lg">
<div class="container">
<a class="navbar-brand" href="#">
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link-home" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Projects</a>
</li>
</ul>
</div>
</div>
</nav>
<section id="mainPage">
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="main-display">
<h1 id="name-title">Mazin Esmail</h1>
<h2>Software Developer</h2>
<h2>Student</h2>
</div>
</div>
</div>
</div>
</section>
<section id="about-me">
<div class="container">
<div class="row">
<div class="heading-about">
<h1 id="aboutme" class="display-5">About me</h1>
<p id="border-line-about"></p>
</div>
<div class="about-page-text">
<h1 id="content-text" class="display-5"></h1>
</div>
</div>
</div>
</section>
<div class="about-me-pics">
<figure>
<figure id="las-vegas-pic">
<img src="https://lh3.googleusercontent.com/pw/AIL4fc8qdQ8Vk4EjS-WJmam9QHz4gAHxNPmlj5PXz_XZW4sYMaHz9VXtZ_JqSX9gj6c8z3lS-Vt-pUAEE7TmPOy1lAFTfyjPFV30Op0nftB2UNislwE0509TxdB-pL7SkgBuJmtO6VsA9p5L_t7jt9h1-KGEFbyEbMBOeC_F_FzSUe8bZYroUej0_lkfpnUVn_iB7BVDSRcxAIr71mXJZTv9YBWQZpxLuyCXyfVCUs20HhkN2qIxccrzQbZlgsDUJhpWgqD1OzwVIqLSsSSWxmkY5lxvX3m6xHYERTSHwMzm71Ll8AUc4qj67vKyO3flFP2DGel2FLW8hhm4tJ_l3utMWl6xr7Xc8gV6sM0kutpUICi7uiIMw9YlgOU9k_xDJ4asMA42chM8LCMRA97hPlypIuAtnp9c9etvFjjppZk0VVDlnfICSMVueWkoXtaXahjktDPJ_uke0Z59W4rWm6KgSo6wVD5Ei5J3D9_nwExGC6eMdRSWME-Y4RymGOerOYmUyOVBoYCQu-ezJbi-_Nihq6yZaX0XxeZERVH5S5XwtkhR5DglsYIrkzU7jKmhT3JgPqkyLRxqBIH_t1tD2KHLXi5mF8MUtSRRVBcmKfivXFpJnSUGvcKXPXebdEeds4yCRwRWh2DWsjVrY9ZSAtOvrBa1AeiIp4EtAU6fG8xyv7b6OC8ezir-luGV3athyHVb-UAgBJHSKuycdiEHJ5QmRfSNvifYQ8QauJo2rhZ3UF2DR1-Pq5DlvZqvNF3y1g8zkdbZCKohSe8iPrD6GsbfqKYE16v6Vh4yReGezm8V3iukafC_Ds8ZDXgW8bJiAM3qhxOR7azNxdmTW3G7AQrM_VVMEwDZqoISAGxprxJifR_K8lPKl5ueTehTD9ZObRv8WvPyAeBGYTsJo-sbJXgZ=w2186-h1640-s-no?authuser=0" height="400" width="350"/>
<figcaption>Las Vegas,Nevada</figcaption>
</figure>
<figure id="basketball-pic">
<img src="https://lh3.googleusercontent.com/pw/AIL4fc-pfdWd5lnospiqJy-bzkxL6FqpxZMGL29BRhPWqxZg9cDHlOSv8tljkeQdR_z6i9YegJBXgS-qvVoAZoXN4Fx0gNiPv2X8Vpy4PkxF2ST3k5rPuV41nBpxmn3jrVjoGI1HZWLEpHa5cYaQ0QQk-WN63jragd0fbOalvI60QGM5zTaaiaBfhCaOuXgXCZBSGp8MoVe8b9fCPedYRWVwgYUR7zfbvuebfeCSE20v_EzcTkFwY-ZL3sjkOBycWmORcJmqORkWx9-D4FSmrMZbWzUlEHJ0gOXW84yq4Bl7PGEV9yZtoxdZ8JC5Jj3_saEepbMi8zDUcQf60n9KirEw2klfxq1BqosrETfNohnnftzwvv3xmx8LoO108Co4EdXYekzARd_UsGXjWywt1NJ1DH0Y2r1WBJMoYwS72ejX4QMiNrHrQOJtbS7D-va7PEitnkF52FO1Fw5UM9_gd_hd0a0DCoQ-gQ026zYR7GJE980li_weB0zWPom6Il3fnMs0vMg3LJcFHHZdULf2mBIf2wlofW6ykI-yl3ZrYGdIvyl6homV84DnVXzdfsWgT99Z-UZyVh50-4b2mjDa_ugvNj0abUG9mTr5dIvd3LbX19oOHBDMGhKP6NNnmr_Cup_k8aGuolR8PtNLLrV93-04bREAZ5vjXq2NNDWxX1IA2XFIvKfMhCrqa6V2BvBepn-goD2Z1wyCS9-Y0kQjbGXNeyjCIjdlAYW1ZopKqO4QkIYtOCz5GckW2kICgP3WajbqN1uWoWjsrMTTzl-y7nAhVnu1W4PBkjd6-80OKDz4wva5Agg0XiSxUQnZeyzxMDF2GWUp2FSlyVruPUShvpkLMzXZ6uY0ZDPJ52zZKjM337kw8oEs2S3YYiUNp6gE3zFhVamAsHTAact95hJJHBrS=w918-h1640-s-no?authuser=0" height="400" width="350"/>
<figcaption>Fontana, California</figcaption>
</figure>
</figure>
</div>
</div>
</div>
</section>
<!-- bootstrap and aos js -->
<script src="assets/js/bootstrap.bundle.min.js"></script>
<script src="https://kit.fontawesome.com/8c2adfc9c1.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script>
AOS.init();
</script>
</body>
</html>
MyCSS
.navbar {
position: absolute;
top: 0;
left: 38%;
translate: -50;
height: 80px;
display: flex;
align-items: center;
font-size: 120%;
}
.nav-link-home{
text-decoration: none;
}
.nav-link{
color: white;
text-decoration: none;
}
.navbar *{
display: inline;
font-size: 100%;
}
@font-face {
font-family: Oswald;
src: url("../fonts/Oswald-Medium.ttf");
}
*{
font-family: Oswald, serif;
}
html{
scroll-behavior: smooth;
}
.nav-item{
color: white;
text-decoration: none;
}
.nav-link-home{
color: white;
}
#mainPage{
background-image: url(https://www.pixelstalk.net/wp-content/uploads/images1/Shadows-Backgrounds-HD.jpg);
min-height: 100vh;
width: 100%;
background-size: cover;
background-position: center;
color:aliceblue;
}
.main-display{
position: absolute;
top: 100%;
left: 50%;
transform: translate(-50%,-50%);
margin-top: 10px;
min-height: 120vh;
text-align: center;
font-family: sans-serif;
animation: fadeInOut;
animation-iteration-count: 2;
animation-duration: 3s;
}
@keyframes fadeInOut {
0%, 100% { opacity: 0; }
50% { opacity: 1; }
}
#about-me{
background-color: tomato;
min-height: 100vh;
width: 100%;
background-size: cover;
background-position: center;
display:grid;
place-items: center;
text-align: center;
}
#border-line-about{
position: relative;
top: 100%;
left: 22%;
margin-top: 90vh;
}
#content-text{
justify-content: center;
text-align: center;
position: relative;
top: -888%;
left: -42%;
}
.about-me-pics {
margin-top: 70px;
display: flex;
flex-direction: row;
justify-content: center;
display: grid;
position: absolute;
transform: translate(-20%,-10%);
bottom: -600px;
left:140px;
height: auto;
width: 10px;
height: auto;
text-align: center;
padding: 50px;
}
#las-vegas-pic {
transform:translate(400px,9%);
align-items: center;
display: block;
position:absolute;
inset:0;
margin: auto;
margin-top: auto;
margin-bottom: auto;
flex-direction: row;
}
#Basketball-pic{
transform:translate(40px,5%);
text-align: center;
display: block;
position:absolute;
inset:0;
margin: auto;
flex-direction: row;
align-items: center;
}
2
Answers
Since you are using Bootstrap for your project, it’s a great idea to refer to Bootstrap’s official documentation and examples to get a better understanding of the framework and its features.
I made several improvements and changes to your code which you can download files here Personal-Project or alternatively here, compare the code changes quickest is to use version control. Here’s a quick summary of the changes I made and what was fixed in your code:
<ul>
element with the class nav-links.Overall, the updated code addresses the issues with image alignment and navigation menu styling that you are having difficulty with. It adopts a more modern and responsive approach by utilizing Bootstrap classes and implementing a clean and organized structure.
The use of CSS Grid and Flexbox for layout and positioning contributes to better alignment and responsiveness of the images in the "about-me-pics" section.
Additionally, as a bonus I added some JavaScript to enhance the navigation menu behavior, ensuring a smoother and more user-friendly experience across different devices.
Hopefully, this helps.
First of all you’re using Bootstrap library so you don’t have to write custom css for it. Just you’ve to use the code to centre the image
Check the link
But before it you’ve follow the structure of Bootstrap like
You can declare a container within section but code should be looks like below