Why would max-width not work on this?
Ah ok, I misunderstood its use. To get a fluid button that won't stretch to massive sizes I added the following:
width:100%;
max-width: 540px;
Thanks commenters!
not able to do max width
So, in your CSS, you can set the word-wrap
property to break-word
so that your string of text (w/ no whitespace) will be made to fit into the max-width:
E.g.
<style type="text/css">
#content {
max-width: 50px;
word-wrap: break-word;
}
</style>
CSS max-width not working
You can set:
#wrapper {
-webkit-box-sizing: border-box; /* Safari, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
width: 100%;
max-width: 1200px;
height: 100px;
margin: 0 auto;
border: 4px solid;
}
not (max-width: 512px) not working
You can use the following media query:
@media not all and (max-width: 512px) { * { color: red; } }
<span>Foobar</span>
Max-Width in CSS not working
The problem is "margin: 0 auto". Remove this or modify it and it works.
margin: 0 auto is basically centering the content, not pushing anything to the right. jsfiddle
div.container {
max-width: 500px;
padding: 0 20px 0 20px;
margin: 0;
}
div with max-width not taking the max width
You're centering the container
using the following code:
position: absolute
top: 50%
left: 50%
transform: translate(-50%, -50%)
When you're giving an element a position: absolute
and giving a left: 50%
, it will automatically move itself and it's subsequent children (if the children doesn't have position: absolute
) to 50%
from the left.
If you want the container to take up the full width, you'll have to remove the following:
position: absolute
top: 50%
left: 50%
transform: translate(-50%, -50%)
Related Topics
How to Replace @Media (Max-Width) Using Stylish or Greasemonkey
How to Use Calibri Font in Linux and Mac
Why <Big> Is Not in HTML 5 Tag List While <Small> Is
Changing The Colors of Rpivottable in Shiny
Compass-Style (Ruby) Encoding Error
Display Two Object Same Real Distance (E.G. Inches) Apart Across Different Browers/Screen Sizes
Text Size Is Different in Ie and Firefox
Using Same Id for Multiple HTML Tags
Correct Way for Writing an <Address> Tag for My Web Site, to Provide Contact Details for Our Company
Preventing High-Contrast Mode in Edge from Adding Background to Text
How Exactly Does Link Rel="Preload" Work
Increase a Div Size on Click with CSS Alone
How to Set This Div to Be The Minimum Possible Width to Display Its Floating Contents
Div with 100% Width of Screen, But Inside a Parent Div with Fixed Width