Friday 15 May 2015

css - Able to set width % but not height -


I am making a beginning in CSS, and I have tried to find the answer but I could not find it. So please bear with me: D

I have a code that is in my code (because it is a responsive mobile web), I will show it in the case related to my problem: < Pre> & lt; Meta name = "viewport" content = "width = device-width, initial-level = 1.0, maximum-scale = 1.0, minimum-scale = 1.0, user-scalable = 0" & gt;

This is a part of my code, where I want to change the img width and height With:

  & lt; Div id = "desc" & gt; & Lt; Img alt = "src =" picture / MallDetail / MallDesc.png "& gt; & Lt; / Div & gt;   

So I tried to do something like this:

  #desc img {float: left; Width: 95%; Height: 50%; Margin: 0 2.5% 0 2.5%; }   

Then there was a strange thing: the width is working perfectly, the img width size is 95% of the current width , But height is not working - it is not currently changing (its height should be 50% of the current height).

I have margin 0 and padding 0 to reset my CSS.

Why is this happening? What should I do to work?

P> You can not set the height by using% Width increases when using% for height width.

You should use the minimum height: 90px; Then the height inside the material increases.

For example.

  & lt; Div id = "mainContainer" & gt; & Lt; Img src = "helloword" alt = "style =" width: 100% "/> & Lt; Div class "newcontent" & gt; & Lt; H1 & gt; Hello & lt; / H1> & Lt; / Div & gt; & Lt; / Div & gt;   

CSS:

  #mainContainer {min-height: 80px; Width: 100%; }    

No comments:

Post a Comment