I'm working on a website for a friend of mine. There's only one problem. The slider won't fit in the frame without stretching.
I've set it to 100% height, but it won't work out. (Its also responsive)
I want it to be a nice image in the original width and height (100x100, 200x200 etc) without stretching (200x500).
I hope you guys can help me out on this.
I'd tried alot and also asked some other people but they can't help me with this.
You can see the slider over here.
http://tinyurl.com/p36hz6u
Here's another version of the slider, but on this version the slider image gets cut off
http://tinyurl.com/nfjjvwu
If the images are background images, consider using the background-size:contain; which will allow the image to grow as large as visible/possible without stretching, and then you can position the background image wherever desired with background-position
If the slides have actual physical <img /> tags, I made a JSfiddle that demonstrates code that will contain an image within an element. In this example, the <div> tags represent a browser window and can be resized: http://jsfiddle.net/dds27w2y/
Firstly what I would do is to remove the: background-size: 100% 100% and add a background-position: center center.
Then I would add a background-color: white to the container. This would make it look nicer and it would be centered.
Related
Okay what i cant seem to figure out is I want any image no matter what size to fit to the browser window EXACTLY corner to corner as a background image. what usually happens is the BG image corners seem to overflow to where they cant be seen. like the browser uses the middle of the image sort of but i need it exact! ANy help, would be greatly apprectiated!!!!....
heres the page link http://www.bxwebdesign.com/stack/index.htm and
http://www.bxwebdesign.com/stack/style.css
You want to use background-size: 100% 100%;. This will fill the element exactly corner to corner with your image.
See https://developer.mozilla.org/en-US/docs/Web/CSS/background-size for documentation on this CSS property.
I'm having a little problem with one of my background images in a div element. I'm using the following CSS:
.myBox
{
background-image:url('....');
background-repeat:no-repeat;
background-size:cover;
}
My background image is a picture with some people on it. Now, if I increase the width of my browser window, at a specific point, some of the people are cutted off (due to the automatic resize of the image with 'background-size:cover').
My question is: Is there any option (or jQuery plugin), to set a specific part on the background image that will be always visible on all window sizes and also fill the whole element?
There are a variety of solutions you could try; however, you might want to start with something simple like applying a background-position.
https://developer.mozilla.org/en-US/docs/Web/CSS/background-position
Using the background image of the group of people as an example, you might set background-position: top so that their heads never get cut off. You can also set the vertical and horizontal position in pixel or percent units.
try boostrap3 img-responsive class
.img-responsive Makes an image responsive (will scale nicely to the
parent element)
http://www.w3schools.com/bootstrap/bootstrap_ref_css_images.asp
Before asking this, I've been googling and trying various things myself....I know this can be accomplished, even though I haven't found a solution anywhwere.
This is the site...
http://spiralout.org
Notice the background image on the body is centrally aligned with the center of the logo (at 1440 wide), yet it's fixed when you scroll. That's great.
How do I make this responsive?
Right now, I'm using background-position at the various breakpoints, but it's not a real solution...for example. It's aligned right now at 1440, but go down to 1280 (the lowest width while keeping 4 columns) or further and you can see what I'm talking about. How do I get the background image to "follow" the logo div?
I've tried using percentages for background-position, but the logo is a different width, and inside the container so it's percentage from the left side of the screen will always vary proportionately to the background image.
I've tried using it as a background-image on the logo div but I don't seem to understand why it doesn't overflow to the top or left. Even if this solution worked, I don't get to keep the fixed position.
Any help is greatly appreciated.
I don't care if the cost/benefit of doing this is ridiculous, or if the solution has to be jQuery, etc. I just want to know how to accomplish it for my own sake :)
If I understood correctly, this is only what it takes me to do it:
body
{
background-image: url('whatever image');
background-repeat: no-repeat;
background-attachment: fixed;
}
I'm trying to set a background image to fullscreen, and on window resize the image doesn't change actuall pixel size, but get's smaller (crop-like).
This is what I mean: (Try to resize window and notice that the picture gets smaller or larger but doesn't pixelate) http://jsfiddle.net/G7Qc4/
Now, the above works because of the image is a background of a div and I've set:
background-position: center top;
If it was just plain <img> it doesn't work which my question is how can I make it work? If there is any way around?
I am using the nivoSlider which doesn't accept div's for image's so I will have to use <img>.
Thanks alot
If I understand, you want to use an actual tag as a background instead of background-image.
Here is my solution:
http://jsfiddle.net/ttZeM/
It requires knowing the dimensions of the background image.
There is a div holding the background which is absolutely positioned, the site content is absolutely positioned on top of it.
To center the background image, I moved it -500px to the left, which is half it's width. It is inside of a div that is 0px wide, being centered with position:absolute; left:50% a strange technique, but it works if you know the image size.
Also note that the bg_wrap div has overflow:hidden; and width:100%; this means you won't see scrollbars off the edges of the screen.
I hope this is what you were after!
It can be done with CSS3 (background-size: cover), like so: http://jsfiddle.net/mqchen/Kq3pa/
Take a look at http://jsfiddle.net/7zb6P/1/
Both the yellow box and the background image are centered in the scrolling div, although their center is slightly different. This seems to be due to the background being centered to the whole area (including scrollbar), but the div being centered to the content area (not including scrollbar) - see it centered correctly without the scrollbar http://jsfiddle.net/7zb6P/2/
Interestingly IE7 renders it "correctly", but IE8+ and other browsers render it as described above.
I have had a play around with background-origin (and -webkit-background-origin) but none of the properties seem to have any effect.
Any ideas on how to solve this?
EDIT: More information: The linked fiddle is just a minimal example of the problem, my actual problem is with whole sites where the is centered (with margin:0 auto) and has a background image centered (using background-position: center top). The solution needs to work on a large number of sites of which I cannot change the HTML, so it needs to be a CSS based (or possibly Javascript based) solution. Thanks.
The problem resides with your background image. You're trying to center an image that (for CSS's purposes) has no center.
The image is 321 pixels wide. Which means the center of the image is 161.5 pixels. As the browser is unable to render that position it gets a 1 pixel offset.