I am a bit new to Angular Material and how to correctly lay things out.
What I am trying to do is have an image at the top of my page that is always the size of the viewable area. Something similar to https://www.rent.com. Notice the top image is exactly the size of the viewable area, no matter if I resize the screen.
Here is what I've tried so far:
html
<div class="container">
<mat-card>
<img mat-card-image src="../../assets/download.jpg" alt="Download image">
</mat-card>
</div>
css
.container {
height: 100vh;
}
This does correctly make the image the same size as the viewable area, but it does that by cutting off the bottom of the image. I would rather have the image stretch/shrink instead of just being cut off, but I am not quite sure how to achieve that.
Related
I've just created some articles in an HTML5 file. Those articles contain images. The articles also have a border at the bottom.
Now I have this problem that whenever you re-size your window to make it larger, the images go outside the border. I want the border to re-size with the image.
Here's an example of how an article looks like in my page:
<article>
<p>
<img image />
</p>
<p>
text
</p>
</article>
The p-tag with the image inside floats left, the p-tag with text floats right next to it.
To be more clear: I want the article tag to resize to the height of the image.
Just guessing, without seeing a working example or any of your CSS, but adding overflow: auto to the article element will cause it to contain its floated children:
article {
overflow: auto;
}
Example that may or may not relate to the CSS we can't see: http://codepen.io/paulroub/pen/opnfG
I am currently trying to design some Call-to-action buttons, and I have made a dynamic width button, which is built by a left and right container and then a middle container holding all the text.
The picture in the middle is a 50 px and repeating.
My problem is, that when the picture is <=50px, the green colours in the background picture appears correct. When it is >50px (and the background-picture is repeating) the green color appears to change.
Does anyone know what I have done wrong?
Here is two pictures showing the problem:
The blurred one: http://d.pr/i/fz2b
The correct one: http://d.pr/i/cjgp
EDIT:
I am doing it as follows:
<a href="#">
<div class="left"></div>
<div class="middle">Link text here</div>
<div class="right"></div>
</a>
My backgrounds in .left and .right aren't repeating. My background-picture is only repeating on overflow - and when it overflows the picture changes it's green color. :-)
you have not done any thing wrong. It is because Image stretches it blur's rather try using png image in a div with proper background color as you desire
Here's an example
Fiddle
Heres a simple html
<div class="cont">
<img src="http://www.iconsdb.com/icons/preview/moth-green/right-circular-xxl.png" class="img"/>
Let me know if you have any doubts
I'm making my first website using Twitter Bootstrap, and am trying to understand why the logo image on my page stops scaling and jumps in size once the screen size reaches a small enough size.
The current behavior makes the site look horrendous on the iPhone.
The image file itself is a 200 x 500 px .gif
Here is a jsfiddle with the code in it: http://www.jsfiddle.net/eugip9/uyGH9
And here is the code from the div it's in:
<div class="row">
<div class="span1">
<img src="./HomePage/logo-02.gif" center alt>
</div>
<div style="text-align:left;padding-top: 5em;text-indent: 5em;"; class="span11">
<h1>Site Title</h1>
</div>
</div>
The image scales well down to a point, but once the screen gets small enough the image goes back to 200px x 500px
I'm using the default bootstrap-responsive.css
Every span has a 100% width when the screen is less than 767px. So, due to every image of the theme has a max-width: 100% property, you image is resizing when the screen is less than 767px.
I recommend you to resize the image to the desirable width with Photoshop (or similar). It's not always a good idea to resize images with CSS. If you don't want to do that, just put a id to the image and then put a max-width: 64px to that logo.
I have a problem.
I am creating a responsive header image, that would scale down to mobile and take the full width of the screen.
I would like to have done this with the img tag, and then applied a max-width of 100% but I wanted to include some text on top of this image, so chose to use a background image instead. I don't want to absolute the text over the images as this causes problems in mobile.
Also, regarding background image, I can't use background-size as this is not supported in ie8.
Is there any other way I can achieve having text over an image, where the image takes full width of the container, and full height of the image?
<div id="container" style="height: 100px; width:100px; display:block;">
<img src="some-img.jpg" style="display:block;"/>
<span style="position:absolute;">Text over image</span>
</div>
Essentially you just need to position the text over the image, within a parent.
z-index property is useful for "stacking" elements visually if you have several competing elements.
I'm creating an iPhone app using PhoneGap and jQuery mobile. I'm using a simple image tag and set the width to 100% and height to auto, but the image is not scaling properly and gets cut off. I have also tried using max-width with the same outcome. Any idea how I can solve this?
<div data-role="page">
<img class="banner" src="..." style="width: 100%; height: auto;">
</div>
I have even tried this:
$('img.banner').each(function(){
$(this).width($(window).width());
});
Previously i have gone through same problem. I tried min-height. And why both maximum-scale=1, minimum-scale=1? Try minimum-scale=1. Just give a try
I'm assuming that your image is actually nested in a div with a data-role="content" and your problem is that class ui-content by default has a 15px padding.
The simplest way to correct that would be to simply override the CSS for that page to get rid of that padding, if you need it for other elements then just wrap them in a div and add padding to those divs.
For example
CSS
.imgContPage { padding:0px; }
Markup
<div data-role="page">
<div data-role="content" class="imgContPage">
<img class="banner" src="http://dummyimage.com/600x400/000/fff.png&text=PlaceHolder" style="width: 100%; height: auto;">
</div>
</div>
Link to JSBin
Alternatively you can set a negative margin on your img to compensate for the padding, but then you will need to calculate the width so that it fills up to the right side.
Ok, I feel very stupid right now. I was getting that image from a JSON response that was coming from a Wordpress website. When I was parsing my JSON to get to the image, I was using the thumbnail version of the image (which in my surprise, it's not really a scaled thumbnail, it's just a cropped 150x150 square of the main image).
So I changed my reference from:
json.page.thumbnail
to
json.page.attachments[0].images.full.url
And now the image scales just fine (width: 100%, height: auto).
Thanks everyone for your helps