html - css min-width does not work properly -


i'm trying position div centered in div code:

<div style="width:100%; height: 300px; background:red;">    <div style="margin:auto; min-width:50%; height:100%; background:green;">text</div>  </div>

it results in big green div that's width 100%. expect 50% though. can tell me why css wont give 50% width , center it?

updated answer

<div style="width:100%; height: 300px; background:red; text-align: center">        <div style="min-width:50%; display: inline-block; height:100%; background:green;">text</div>  </div>


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -