Forum Discussion
Cr8tiveThe
Jun 27, 2024Copper Contributor
A few issues with ASP.NET, HTML, and CSS.
What I am trying to do - Get the div #menu to display menu in the center (horizontally and vertically) between and not past (horizontally and vertically) the logo images. Basically, center horizonta...
Abhishek_Khatri
Jul 16, 2024Brass Contributor
Hi try this one I think it will help if not please let me know then we together find solution for it
/* Ensure body and html use full height */
body, html {
height: 100%;
margin: 0;
display: flex;
flex-direction: column;
}
/* Ensure form takes up full height and distributes space */
form {
flex: 1;
display: flex;
flex-direction: column;
}
/* Header container using flexbox to center elements */
#HeaderContainer {
display: flex;
align-items: center;
justify-content: space-between;
position: relative; /* Ensure this element positions its children properly */
}
/* Styling for the left logo */
#HeaderLogo {
width: 200px;
float: left;
}
/* Styling for the right logo */
#MainTile {
width: 200px;
float: right;
}
/* Center the menu between the logos */
#Menu {
display: flex;
justify-content: center;
position: absolute; /* Position the menu absolutely within the header container */
left: 50%; /* Move the menu to the horizontal center */
transform: translateX(-50%); /* Adjust the position to truly center it */
text-align: center;
}
/* Allow main content to take available space */
#MainContentPlaceHolder1 {
flex: 1;
min-height: 550px;
border: 5px solid black;
}
/* Clearfix for floating elements */
.clearfix::after {
content: "";
clear: both;
display: table;
}
/* Footer should stay at the bottom */
#Footer {
width: 100%;
height: 75px;
background-color: black;
}
#TestBar {
width: 100%;
height: 100px;
background-color: silver;
}
/* Ensure body and html use full height */
body, html {
height: 100%;
margin: 0;
display: flex;
flex-direction: column;
}
/* Ensure form takes up full height and distributes space */
form {
flex: 1;
display: flex;
flex-direction: column;
}
/* Header container using flexbox to center elements */
#HeaderContainer {
display: flex;
align-items: center;
justify-content: space-between;
position: relative; /* Ensure this element positions its children properly */
}
/* Styling for the left logo */
#HeaderLogo {
width: 200px;
float: left;
}
/* Styling for the right logo */
#MainTile {
width: 200px;
float: right;
}
/* Center the menu between the logos */
#Menu {
display: flex;
justify-content: center;
position: absolute; /* Position the menu absolutely within the header container */
left: 50%; /* Move the menu to the horizontal center */
transform: translateX(-50%); /* Adjust the position to truly center it */
text-align: center;
}
/* Allow main content to take available space */
#MainContentPlaceHolder1 {
flex: 1;
min-height: 550px;
border: 5px solid black;
}
/* Clearfix for floating elements */
.clearfix::after {
content: "";
clear: both;
display: table;
}
/* Footer should stay at the bottom */
#Footer {
width: 100%;
height: 75px;
background-color: black;
}
#TestBar {
width: 100%;
height: 100px;
background-color: silver;
}