I am in need of some assistance.
I am currently working on a site that is going to be responsive.
Will post a link to an image of the psd of the site so you have an idea what it is supposed to be like.
Link to the site itself
the site has a width of 1200px as you scale the site you will see that the boat will do nothing
Now to the problem.
the problem lays with the boat this img is 1019x1732 and is positioned absolute. And needs to be so because i have to use the z-index to be able to position it above some other divs for it is rather big.
I have tried to put it in as a background-image and as an img tag with a relative div around it. but nothing happens.
My appolagies if my question is a hard to understand. have a hard time explaining problems to other people, it always makes more sence in my head.
Here is my code:
my html
<div id="wrapperHero">
<div id="hero">
<p>The "Banarly Group" has been operating<br>
in Nigerian, Gabonese and Cameroon waters<br>
since 1995.
</p>
<div id="circle">
<p>a fleet of<br>
<span class="number">24</span><span class="trawler">trawlers</p>
</div>
</div>
<div id="boat">
<img src="img/BAN_herofg.png" alt="boat">
</div>
</div>
My css:
#wrapperHero {
width: 100%;
background-image: url(../img/BAN_herobg.png);
background-repeat: repeat-x;
min-height: 795px;
margin-top: -23px;}
#hero {
max-width: 1200px;
width: 100%;
height: 100%;
margin: 0 auto;}
#boat {
background-image: url(../img/BAN_herofg.png);
background-repeat: no-repeat;
position: absolute;
height: 100%;
width: 100%;
z-index: 1;
right: -6%;
top: 240px;}
#circle {
border-radius: 50%;
width: 18.3333%;
min-height: 220px;
background-color: #fff;
background-color: rgba(255,255,255,0.2);
float: right;
margin: -230px 21.6666% 0 0;}
1:
You can use background-size , background-position-x with different media :)
#boat {
background-size: 590px;
background-position-x: 79px;
}
#media (min-width: 450px) and (max-width: 960px) {
#boat {background-size: //use different size;
background-position-x://use different size;}
}
If I got the question right, here's what you should do:
remove the background-image property from #boat
create <img src="img/BAN_herofg"> inside
set max-width: 100% to <img>.
Hope this will solve your problem.
Use css media queries to solve your problem...
ex:
#media (min-width: 600px) and (max-width: 800px) {
html { background: red; }
}
Related
So i have this problem with an image, which won't load in my responsive.css code. I'm trying to change a background image according to various resolutions of the website. below i post the parts of my codes in html and responsive.css. I already checked the path to the image and the image is in the file which contains html, css, responsive. Any tips how to make it work? I'm a beginner when it comes to html and css.
HTML:
#background {
width: 100vw;
background-position: center;
background-size: cover;
}
responsive.css: figure {
width: 100%;
}
#media (max-width: 992px) {
#background {
height: 50vh;
}
}
#media (min-width: 993px) and (max-width: 1170px) {
#background {
height: 70%;
width: 100%;
background-image: url('../zadanie-domowe-rwd-materialy/obrazy/man-2.jpg');
}
}
<figure>
<img src="zadanie-domowe-rwd-materialy/obrazy/man-1.jpg" alt="Zdjęcie nr 1" id="background">
</figure>
Your HTML needs an amendment:
<body>
<figure id="background"></figure>
</body>
Remove the img tag and apply an id of background to the figure tag.
Img tags are not background images, so all images will appear on top of backgrounds. To create the condition, both images need to be added within css as background-image
You will need to add this to your css too:
#background {
position: relative;
height: 500px; // Or a different height
width: 100%; // Change to 100% of element or window
background-position: center;
background-size: cover;
// Add the follow
background-image: url('../zadanie-domowe-rwd-materialy/obrazy/man-1.jpg');
}
Update: Entire Code
HTML
<body>
<figure id="background"></figure>
</body>
CSS
#background {
position: relative;
height: 500px; // Or a different height
width: 100%; // Change to 100% of element or window
background-position: center center;
background-size: cover;
background-image: url('http://placehold.it/350x150');
}
#media (min-width: 992px) and (max-width: 1170px) {
#background {
background-image: url('https://unsplash.it/200/300');
}
}
See JsFiddle
I hope this helps
For responsive only change .css file not HTML . if you want to change the img in mobile or other device ing use in css Like this
Try it i thing it's helpful . https://jsfiddle.net/dup1d62k/4/
Newbie here hacking away at this little project:
http://development.puretapecult.divshot.io/
And my question is, how do I automatically resize the .pngs in the center of the screen when the browser size collapses, or when it is viewed on a mobile browser?
Do I have to use #media queries for mutliple viewing sizes, and create multiple classes for each png?
Any help appreciated.
CSS classes that modify the images:
.spinner-outer {
display: block;
width: 327px;
height: 327px;
position: absolute;
left: 50%;
margin-left: -163px;
border-radius: 50%;
background: url(spinner-outer.png) center center no-repeat #32302e;
}
.spinner-center {
height: 200px;
width: 200px;
position: absolute;
background: url(spinner-center.png) center center no-repeat;
border-radius: 50%;
left: 50%;
top: 50%;
margin: -99px;
pointer-events: none;
}
.play-sprite {
position: absolute;
top: 50%;
left: 50%;
margin: -35px 0 0 -35px;
background: url(play-sprite.png) 0px 0px no-repeat;
height: 70px;
width: 70px;
}
I would use media queries to change the height and width of the divs. Note that you do not need to create multiple classes for different sizes. Just use multiple media queries like this:
#media (max-width: 768px) {
.spinner-outer {
width: 200px;
height: 200px;
}
}
You'll also need to specify that you want your background image to fit the size of the div or it won't change sizes when the div does. Use the CSS3 property background-size as long as you're comfortable not supporting old browsers.
.spinner-outer {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
More info on background-size and some alternative techniques if you want to support older browsers: https://css-tricks.com/perfect-full-page-background-image/.
Try somthing like this.
HTML:
<div class="image-wrapper">// Div will always re-size with page.
<img src="[src]" />
</div>
CSS:
.image-wrapper{
max-width:90%;
height:auto !important;
position: relative;
display:block;
margin:0 auto;
}
.image-wrapper img{
max-width:100% !important;
height:auto !important;
display:block;
}
Or you can use bootstrap and add a class to image like so.
.img-responsive
Makes an image responsive (will scale nicely to the parent element)
<img src="[src]" class="img-responsive" alt="[Alt]">
I have to make a website for my html class.
When I open the page on my computer, the images fit how I want them to fit.
But when I try to open it on the school computers, it is like 50% of what I expect it to be. I'm guessing its because of different screen resolutions. How do I make it work on all resolutions?
Here's a picture.
http://i.imgur.com/7YsCSpa.png
The logo on the top stays in position but the pink bar wont. It doesnt fill across the entire screen.
My html is <div id="headbar">
<img src="headbar.png" alt="bar" />
</div>
My css is
#headbar {
position: fixed;
margin-top: 85px;
width: 100%;
z-index: -1;
background-attachment: fixed;
Use Media Queries in CSS.
Example:
#media (min-width: 1200px) and (max-width: 1400px) {
#headbar {
position: fixed;
margin-top: 85px;
width: 100%;
z-index: -1;
background-attachment: fixed;
}
#media (min-width: 800px) and (max-width: 1200px) {
#headbar {
position: fixed;
margin-top: 35px;
width: 100%;
z-index: -1;
background-attachment: fixed;
}
Is headbar.png a image that should make #headbar fully pink? Then it could be as simple as :
#headbar img {width: 100%}
It will then be scaled though. To prevent this, give #headbar a height and make the image 100% height. Of course it would make more sense to make it a background image (or color if it is pink only).
Edit - going on current information, would this be what you're after?
#headbar {
width: 100%;
height: 50px;
position: fixed;
margin-top: 85px;
z-index: -1;
background-image: url(headbar.png);
background-size: 100% 100%
}
I've just added some height - adapt this to what fits best. One more thing to beware of is to get the correct path to the image (absolute url is easiest)
background-image: url(/imagefolder/headbar.png);
I want to insert an image by CSS because I want to use captions over my image.
What I want is that the image shows completely and is responsive.
Can anyone help me with this?
Here you can see my HTML im using bootstrap. As you can see i want to let contentblock1 show an responsive image by using the CSS background-image code. I also want this background image to be responsive. But whatever i try it won't show me the background.
<div class="container">
<div class="col-sm-6">
<h1> Dit is een bootstrap site</h1>
<button type="button">click me!</button>
</div>
<div class="col-sm-6">
<div class="contentblock1">
</div>
</div>
I'm using the following CSS
.contentblock1 {
background-image: url('http://1.bp.blogspot.com/_zxdOSKs0ASI/TDMqbnatRwI/AAAAAAAAAkM/nB-DxcVcqqk/s1600/Testbeeld.jpg');
background-size: 100% 100%;
width: 100%;
}
width: 100px; /*you width*/
height: 100px; /*you height*/
/* optional: background-color: white; */
background-image: url('image.png');
background-repeat: none;
background-size: 100% 100%;
/*or
background-size: cover;
background-position: 50% 50%;*/
background-attachment: fixed;
#some-div {
background-image: <imgurl>;
background-repeat: none; //Unless you want something else
backgorund-size: 100% 100%;
}
and for responsiveness, use media-queries or a lib that is made for responsiveness such as Bootstrap.
Below you have an example of media-queries.
#media (min-width: 1200px)
{
#some-div {
width: 600px;
}
}
#media (max-width: 768px)
{
#some-div {
width: 100%;
}
}
EDIT:
http://jsfiddle.net/e8xLf4u3/
Here is your working example, it only needed content. Also, in the future please show some code for faster help and better understanding
Graag gedaan ;)
So I'm trying to show off a mobile site within a div that looks like a smartphone that is placed on a responsive html5 site. I've messed with the CSS so that the smartphone div keeps a solid aspect ratio as the width of the window is adjusted. Now I am trying to fit an iframe within the div to simulate the phone's screen. The problem I run into is that my responsive CSS trick is messing with the position of the screen.
Here is a jFiddle: http://jsfiddle.net/E6X4j/2/
I've tried to position it relative, but that messes with the responsive trick in CSS. Any suggestions?
HTML:
<div id="smartphonewidth">
<div id="smartphoneheight">
<object type="text/html" data="http://www.engadget.com" style="width:100%; height:100%;">
</object>
</div>
CSS:
#smartphonewidth {
margin-left: 5%;
background-image: url('http://i.imgur.com/lavEp8B.png?1?5267');
background-repeat: no-repeat;
width: 50%;
padding: 20%;
background-size: 100% 100%;}
#smartphoneheight {
position: absolute;}
Use this link CSS3 media queries for reponsive design
To target small devices we can use the following syntax:
#media only screen and (max-device-width: 480px) {
//your css here
}
please check this JSFIDDLE
CSS:
#smartphonewidth {
margin-left: 5%;
background-image: url('http://i.imgur.com/lavEp8B.png?1?5267');
background-repeat: no-repeat;
width: 50%;
padding: 20%;
background-size: 100% 100%;
}
#smartphoneheight {
position: relative;
z-index:1;
width:100%;
height:100%;
}
FIDDLE
#smartphonewidth {
margin-left: 5%;
background-image: url('http://i.imgur.com/lavEp8B.png?1?5267');
background-repeat: no-repeat;
width: 58%;
padding: 15%;
background-size: 100% 100%;
}
#smartphoneheight {
height: 15%;
position: relative;
margin-bottom: -69px;
margin-top: -50px;
}
<div id="smartphonewidth">
<div id="smartphoneheight">
<object type="text/html" data="http://www.engadget.com" style="width:100%; height:70%;">
</object>
</div>
</div>