I made a site so when you click the button 30px it changes the font inside the div
.
I have a ul
inside it with the bottons. When I change the size of font the div
expands and the nav buttons move with it as well.
How do i make it so it stays fixed but the fonts can still change.
Answer: Use the CSS display Property You can simply use the CSS display property with the value inline-block to make a <div> not larger than its contents (i.e. only expand to as wide as its contents).
Using width, max-width and margin: auto; Setting the width of a block-level element will prevent it from stretching out to the edges of its container. Then, you can set the margins to auto, to horizontally center the element within its container.
What you could do is set your div to be position: absolute so your div is independent of the rest of the layout. Then say width: 100% to have it fill the screen width. Now just use margin-left: 30px (or whatever px you need) and you should be done.
Try the following css:
#innerbox { width:250px; /* or whatever width you want. */ max-width:250px; /* or whatever width you want. */ display: inline-block; }
This makes the div take as little space as possible, and its width is defined by the css.
// Expanded answer
To make the buttons fixed widths do the following :
#innerbox input { width:150px; /* or whatever width you want. */ max-width:150px; /* or whatever width you want. */ }
However, you should be aware that as the size of the text changes, so does the space needed to display it. As such, it's natural that the containers need to expand. You should perhaps review what you are trying to do; and maybe have some predefined classes that you alter on the fly using javascript to ensure the content placement is perfect.
you can give it a max-height and max-width in your .css
.fontpixel{max-width:200px; max-height:200px;}
in addition to your height and width properties
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With