I'm having some trouble with a responsive design. The first that I have tried to create.
For some reason when I view the site on my iphone everything is zoomed in.
What I want is; On the desktop site, the logo will sit left in the '.container' and when viewed on an iPhone the image will sit directly in the middle.
Here is the URL: http://markpetherbridge.co.uk/peak.
I have added this into the html header:
meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"
this is the relevant CSS:
<div class="wrapper">
<div class="container" id="header">
<div id="peak-logo">
<img src="img/peak-logo.png" alt="Peak Architects" />
</div>
</div>
</div><!-- end.Header !-->
My desktop CSS is:
/* structure */
body {
font-family: "Calibri", Helvetica, Arial, Sans-Serif;
font-size: 16px;
color: #8d8c8c;
}
.wrapper {
float: left;
top: 0px;
left: 0px;
width: 100%;
background-color: #333;
}
.container {
position: relative;
width: 1000px;
height: 100px;
background-color: #ccc;
margin: 0 auto;
}
and the CSS for the phone is:
#media screen and (max-width: 480px) {
body {
}
.wrapper {
max-width: 480px;
}
.container {
width: 100%;
max-width: 480px;
}
#peak-logo {
display: block;
margin: 0 auto;
text-align: center;
position: relative;
width: 200px;
min-width: 480px;
margin: 20px 0;
}
}
It seems to work in the browser just not when viewed on an actual phone device.
This will work when #media screen takes effect.
http://jsfiddle.net/Enxu2/1/
You have a few issues because of your minimum width being set to specific pixels. For a mobile atmosphere you need to use a % so it can adapt to the viewport. Once you set something to width: 100% you need to be conscious of your left/right margins and padding as it can move elements outside of where they should be and allow the user to zoom in and out on your page instead of it fitting perfectly. An easy way to fix this if you are having some elements outside of your defined borders you can try changing some width:100% to width: 95% or even 90%. This should allow you to see which elements are causing the problem.
In the jsfiddle provided I changed some widths and some margins. I hope this will help you get on the right track!
#peak-logo {
display: block;
margin: 0 auto;
text-align: center;
position: relative;
width: 100%;
min-width: 100%;
}
.wrapper {
width: 100%;
}
.container {
width: 100%;
}
.container img {
width: 100%
}
You also need to make sure your image will be responsive, so you need to set it to a % width also. if you have a max width/height for the image you can always define it in the css using max-width: or max-height: but keep in mind your viewports.
I hope this helps!
Related
When running my login page on IE 11 with a screen size of less than 700px, the site looks like this:
The space on the right hand side that causes scrollbars that should not exist. I usually would assume that there is something overflowing, but I don't see any content that would cause this behaviour.
Here is a rundown of the page's code:
https://codepen.io/bitz/full/brayEb/
I was thinking that it has something to do with the way I set the width:
html {
height: 100%;
width: 100%;
margin: 0;
background: rgb(90, 103, 113);
font-family: Arial !important;
font-size: 12px !important;
}
But I tried changing it a bit to no effect.
Try to take this off from your CSS
#media only screen and (max-width: 1000px) {
body#login-body
{
background-size: contain;
}
}
Turns out IE does not like transform css at all, so I opted to center the objects in a different way, as outlined here.
Basically:
.outer {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.middle {
display: table-cell;
vertical-align: middle;
}
.inner {
margin-left: auto;
margin-right: auto;
width: /*whatever width you want*/;
}
Instead of the system that was used in the codepen.
I was making the main of the site today and I added two <div>s. I made it perfectly so on every monitor it will display the same. However, when I tried opening it on my phone on portrait mode, the title is bigger than the free space for the <div> and the two <div>s are going one under one.
It’s OK for me because there are phones with a much smaller screen than mine. But the <div> size is staying the same; it’s not going up to 100% to fit all the screen if it’s one under one. It’s staying the same 70% and 30% and it’s awful. Here are some images of that:
And this is the code:
#glavno {
width: 100%;
height: auto;
margin-left: auto;
margin-right: auto;
}
.reklami {
display: inline-table;
width: 30%;
height: auto;
margin: 0;
top: 0;
}
.novo {
display: inline-table;
top: 0;
width: 70%;
height: auto;
margin: 0;
}
.naslovnovosti {
font-size: 2em;
background-color: #41c2ac;
color: white;
width: 100%;
}
.naslovreklami {
font-size: 2em;
background-color: #41c2ac;
color: white;
width: 100%;
}
<div id="glavno">
<div class="novo">
<div class="naslovnovosti">
Новости
</div>
novost1
<hr>novost2
<hr>novost3
<hr>novost4
<hr>novost1 novost2 novost3 novost4
</div>
<div class="reklami">
<div class="naslovreklami">
Реклами
</div>
deneska se sluci cudo vo valandovo
<hr>novost2
<hr>novost3
<hr>novost4
<hr>
</div>
</div>
You need to add a #media rule in your CSS, instructing the browser to substitute 100% (instead of 70% and 30%) as soon as the window width is less than X, where X is what you think to be the good choice for this to happen.
It'd look like this:
#media screen and (max-width: 480px) {
.reklami {width: 100%;}
.novo {width: 100%;}
}
I have another problem.
I made a #wrapper in my page to control width of content, but...
It's not working on bigger screens than 1366px.
Tested it on 1920 screen and in debugger page has total width of wrapper (not 1920 but 1244px (wrapper width)).
Same problem was on 4k TV - Page was "scaled" to wrapper width.
It looks like full width of page was wrapper and "width: 100%" on body/sections were ignored.
Any idea where is problem?
Without !important on wrapper its same, max/min width not working. Changing units to vw not working also. Removing/changing meta tag not working. There is no other tags that overwrite wrapper. Styles has been cleared by SCSS Reset at start.
What Im doing wrong?
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.aaa {
width: 100%;
height: 300px;
}
#wrapper {
width: 1224px !important;
margin: 0 auto !important;
}
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<section class="aaa">
<div id="wrapper">
<h2>content</h2>
</div>
</section>
</body>
</html>
it should be like that:
[-margin-[-wrapper 1224px-]-margin-]
[------------------1920px-----------------]
And its like that on 1920px resolution:
[--wrapper 1224px----]
[-1224px in debugger-]
Even if screen resolution is 1920px
There is link to cleared page: www.xileo.pl
And img from 4k screen:
As you can see, there is 3840px screen, where wrapper is scaled to 3840px and its not 1224px with margins.
I want it to be on 1224 px with margins.
If i understood you correctly, try this:
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.aaa {
width: 100%;
height: 300px;
}
#wrapper {
max-width: 1224px;
margin: 0 auto;
}
Provide a jsfiddle if this is not helping you.
*Edit added a screen from near 4k resolution, your screenshot is not from true 4k device, it is maybe scaled or something else is going on so you need to figure that one with some kind of debuging. All else behaving as expected. You might have something else in ur css files that maybe override your code, so you partial code you posted is working as expected.
Updated:
https://jsfiddle.net/8yt3fp0k/ the css works, definitely something wrong with the SCSS, probably another #wrapper is definned somewhere else out of the snipped provided.
css:
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.aaa {
width: 100%;
height: 300px;
}
#wrapper {
width: 1224px;
margin: 0 auto;
}
If you want it to be different on bigger resolution, than change width:
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.aaa {
width: 100%;
height: 300px;
}
#wrapper {
width: 1224px;
margin: 0 auto;
}
#media only screen and (max-device-width: 1224px) {
#wrapper {
width: 100%;
margin: 0 auto;
}
}
New answer after question edit and posted link to original website:
You have this rule:
.index .main-page .main .main-box .about-us {
width: 100%;
padding-right: 370px;
}
This gives the upper text block a very large right padding which diminishes its width. You can erase that rule to strecht about-us across the full width of the wrapper.
However, if you want .about-us to be narrower and horizontally centered inside the first wrapper, change that rule to
.index .main-page .main .main-box .about-us {
width: 1224px; /* any value you like */
position: relative;
margin: 0 auto;
}
Also, note two more things:
1.) wrapper has the 1224px limitation and is also used inside the other sections. So if you want the subsequent section (the one with the four text blocks) to stretch across a wider screen, change the width and max-width values in the wrapper rule
2.) You are using wrapper more than once. But it is bound to an ID, which should only be used once per page. So you should change #wrapper to .wrapper in the CSS and all id = "wrapper" attributes in your HTML elements to class = "wrapper"
I am creating a simple wordpress theme for this website and style.css applied on this site.
i want all images to be responsive. I tried this code.
img {
max-width: 100%;
height: auto;
}
It is not working unfortunately. If you try to resize the browser, the logo and the image is not resizing according to browser width (unresponsive).
How do i fix this?
Sorry for being so naive, been working on this for 2 days, still cant seem to find a solution for this simple problem.
Instead of max-width: 100%; try the following:
img {
max-width: 200px; /* Change this to what your logo is by its width */
width: 100%;
height: auto;
}
You can also set the max-width to be more than what your logo actually is, but of course it is suggested to keep it at high quality and in control.
EDIT: For sitewide images this of course does not work, since they all don't have the same width.
For image tag write this css
img {
max-width: 100%;
height: auto;
width:100%;
}
And if you are using bootstrap in your theme then write this css
img {
max-width: 100%;
height: auto;
width:100%;
display:inline-block;
}
You can wrap the images in a div, with a media query for true mobile. Here I made a version that's three images across and turn into stacked images on mobile, resizing along the way: Example is here
<div class="image-wrap">
<img alt="" src="http://test.amtamassage.org/wp-content/uploads/5904-thumb-290x220-cropped.jpg">
</div>
<div class="image-wrap">
<img alt="" src="http://test.amtamassage.org/wp-content/uploads/5904-thumb-290x220-cropped.jpg">
</div>
<div class="image-wrap">
<img alt="" src="http://test.amtamassage.org/wp-content/uploads/5904-thumb-290x220-cropped.jpg">
</div>
And the CSS:
.image-wrap {
max-width: 600px;
width: 30%;
margin: 2% 0 0 2%;
overflow: hidden;
position: relative;
display: inline;
float: left; }
img {
width: 100%;
height: auto; }
#media only screen and (max-width: 767px) {
.image-wrap {
width: 96%;
max-width: 400px;
display: block;
float: none;
margin: 0 auto;
margin-top: 2%;}
}
I would like to have a image on the left with a heading on the right. I want both of them to scale in size and spacing as the page is shrunk. I have used this code: width: 10%; height: auto; margin: 2% 0px; to have the image on the top left of my page and scale in both spacing and size to the page when the browser is shrunk (I have also included media queries which wouldn't think would make a difference). I have tried using positioning: absolute which doesn't work. I am a novice to using HTML5 and CSS3. This is my first project and second post on Stack Overflow.
I think this is what you are trying to do
HTML
<div class="wrapper"><img src="yourimage.jpg"/><h1>my Heading Goes here</h1></div>
CSS
div.wrapper {
width: 100%;
height: auto;
max-width: 600px;
border: thin solid #333;
}
div.wrapper:after {
content: '';
display: block;
clear: both;
}
div.wrapper img {
display: block;
float: left; width: 40%;
height: auto;
margin-right: 5%;
}
div.h1 {
display: inline-block;
line-height: 20px;
margin: 0px;
padding: 0px;
}
You can check it here
jsfidlle
Could you make a http://jsfiddle.net/?
It's kinda hard to understand what you're after based on our description alone.