Exploring the centering of a particular div:
#container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 550px;
width: auto;
background: rgba(28, 28, 54, 0.70);
padding: 15px;
border: 1px solid #1c1d29;
border-radius: 3px;
display: flex;
}
#actualcontainer {
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin: 5px;
}
#content {
width: 550px;
height: 100%;
background-color: #1c1c36;
padding: 25px;
border-radius: 3px;
align-items: center;
justify-content: center;
display: inline-block;
overflow-y: auto;
overflow-x: clip;
box-sizing: border-box;
}
#sidebar {
width: 300px;
height: 100%;
background: transparent;
overflow-y: none;
text-align: center;
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
padding-left: 20px;
}
#sidebar p {
text-align: center;
}
#sidebar img {
max-width: 300px;
text-align: center;
}
.sideimage {
vertical-align: top;
margin: 0 auto;
background-image: url('/img.jpg');
background-size: cover;
background-repeat: no-repeat;
width: 150px;
height: 150px;
border-radius: 50%;
text-align: center;
}
#title {
font-size: 175%;
font-weight: bold;
text-align: center;
margin: 10px 0;
}
#description {
font-size: 90%;
padding: 0 10px;
width: auto;
max-height: 135px;
box-sizing: border-box;
overflow-y: auto;
text-align: center;
margin: -10px 0;
}
#linkcontainer {
position: absolute;
bottom: 0px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
#links {
font-size: 14px;
color: #f7e5a3;
padding: 5px;
overflow: hidden;
background: rgba(28, 28, 54, 0.70);
border-radius: 3px;
width: 75px;
height: 75px;
box-sizing: border-box;
margin: 3px 3px 1.5px 3px;
line-height: 200%;
display: flex;
justify-content: center;
align-items: center;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
}
Looking at the HTML structure:
<div id="container">
<div id="actualcontainer">
<div id="content">
<h1>Text text text</h1>
<p align="center">Text text text</p>
</div>
<div id="sidebar">
<div class="sideimage"></div>
<div id="title">Text text text</div>
<div id="description">
<p>Text text text Text text text Text text text</p>
</div>
<div id="linkcontainer">
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
<div id="links"><a href="/link"><i class="fa-solid fa-house"></i><br>link</a></div>
</div>
</div>
</div>
</div>
The current situation:
- On desktop: everything is centered correctly with no parts extending beyond the window.
- On mobile (portrait mode): also centered properly and content scales to fit screen size.
- On mobile (landscape mode): container becomes too large for screen and top/bottom edges are cut off.
Desired outcome: To have consistent scaling in both portrait and landscape modes on mobile devices, ensuring visible space around the container without any cutoffs.
Attempts so far:
- Adjusting sizes via CSS: The code provided reflects adjustments made but issues remain.
- Using media queries and transform property:
- Applying
@media (max-width: 600px)
and scaling#container
: No noticeable change. - Applying
@media (max-height: 600px)
and scaling#container
: Container shrinks but gets misaligned to bottom right requiring scrolling. - Scaling using
@media (max-width: 600px)
onbody
: Container shrinks but shifts to top edge cutting off part of it with no scroll option. - Similar results seen when applying scale to
body
using@media (max-height: 600px)
.
- Applying