Here’s a picture of the website
I am using button code from UIverse and I have them aligned to the center.
My only issue here is that when I use another screen size the buttons come out of the div. The code I am using will be listed below in a codeblock. If anyone can help I would love this. I’m making a concept website for my school. The image above shows how ‘Organizations’ is out of the orange div. I need it aligned in center inside the div so it’s flexible on screen sizes.
I would love some help, Thanks!
button {
--hover-shadows: 16px 16px 33px #ffffff,
-16px -16px 33px #ffffff00;
--accent: rgb(255, 255, 255);
font-weight: bold;
letter-spacing: 0.1em;
border-radius: 1.1em;
background-color: #ff7300;
color: white;
padding: 1em 2em;
transition: box-shadow ease-in-out 0.3s,
background-color ease-in-out 0.1s,
letter-spacing ease-in-out 0.1s,
transform ease-in-out 0.1s;
border: solid;
border-width: 3px;
border-color: #ffffff;
display: block;
margin: 0 auto;
}
button:hover {
box-shadow: var(--hover-shadows);
}
button:active {
box-shadow: var(--hover-shadows),
var(--accent) 0px 0px 30px 5px;
background-color: var(--accent);
transform: scale(0.95);
}
#navbuttons {
height: 60px;
text-align: center;
background-color: #ff7300;
vertical-align: middle;
}
#Theactualbuttons {
position: relative;
top: 15%;
vertical-align: middle;
I have tried changing the flex values and margin values, it didn’t seem to work really well.
3
Answers
Thanks for all the answers. I used the code listed below to fix it. Thanks for the help.
Edit: I pasted the wrong thing. This is the actual code I used. I also upped the div sizes a bit. Thanks for all the help!
I would use a flex-box with justify set to centre or space-evenly
the following link describes their use nicely
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
rough example:
CSS
HTML
Set width and height for the div container (can bee %) and button position to relative.