Scale image to fit a bounding box

Thanks to CSS3 there is a solution ! The solution is to put the image as background-image and then set the background-size to contain. HTML <div class=”bounding-box”> </div> CSS .bounding-box { background-image: url(…); background-repeat: no-repeat; background-size: contain; } Test it here: http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=contain Full compatibility with latest browsers: http://caniuse.com/background-img-opts To align the div in the center, … Read more

Android: why is there no maxHeight for a View?

None of these solutions worked for what I needed which was a ScrollView set to wrap_content but having a maxHeight so it would stop expanding after a certain point and start scrolling. I just simply overrode the onMeasure method in ScrollView. @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(300, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec); … Read more

How to get StackPanel’s children to fill maximum space downward?

It sounds like you want a StackPanel where the final element uses up all the remaining space. But why not use a DockPanel? Decorate the other elements in the DockPanel with DockPanel.Dock=”Top”, and then your help control can fill the remaining space. XAML: <DockPanel Width=”200″ Height=”200″ Background=”PowderBlue”> <TextBlock DockPanel.Dock=”Top”>Something</TextBlock> <TextBlock DockPanel.Dock=”Top”>Something else</TextBlock> <DockPanel HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” … Read more

How do I auto-resize an image to fit a ‘div’ container?

Do not apply an explicit width or height to the image tag. Instead, give it: max-width:100%; max-height:100%; Also, height: auto; if you want to specify a width only. Example: http://jsfiddle.net/xwrvxser/1/ img { max-width: 100%; max-height: 100%; } .portrait { height: 80px; width: 30px; } .landscape { height: 30px; width: 80px; } .square { height: 75px; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)