Font breaks responsive design? - html

I'm having a problem with a design I'm coding that I intend to make creative. Right now, I have a header that has 3 separate areas, one div in the middle with 30% width and two on either side with 35%. In these I contain my header elements. The middle one contains my logo, which scales just fine. When I re size the window it scales down and maintains it's positioning inside the div.
The problem arises when I try to add the navigation on either side. I have the navigation text inside the first div currently, and it doesn't behave how I intend it to. I have it relatively positioned and it doesn't maintain that positioning. When the browser is re-sized the text remains fixed, so at some point, as the divs grow smaller, the text is completely outside it's containing div. Also, at some point the text begins to stack instead of maintaining it's in-line style. I have a separate style sheet that has a few font size media queries to remedy this, they simply drop the font size at certain intervals, but this doesn't do anything. The text gets smaller, but still remains fixed on re-size and breaks out as well as begins to stack.
I simply cannot figure out why this is happening. The logo image remains perfectly in it's div and maintains it's position whilst the text doesn't move at all. I guess I'm just not understanding text properties as well as I need to I've included the HTML and CSS below, I left out the media queries as it's pretty self explanatory.
<div id=container>
<div id=header>
<div id=headerone>
<div id=leftnav>
<ul>
<li>Home</li>
<li>Services</li>
</ul>
</div>
</div>
<div id=headertwo>
<img src="images/title.png">
</div>
<div id=headerthree>
</div>
</div>
and the CSS
html, body {
width: 100%;
height: 100%;
margin:0;
font-size: 100%;
padding:0;
}
img {
max-width:100%;
width: 100%;
}
ul {
list-style: none;
}
ul li{
text-decoration: none;
color: white;
display: inline-block;
padding: 20px;
}
#container{
width: 100%;
height: 100%;
}
#header{
background-size: auto 100%;
width: 100%;
height: 19.1%;
background-image: url(images/headerbg2.jpg);
}
#header img{
width: 70%;
position: relative;
left: 15%;
top: 30%;
}
#headerone{
width: 35%;
height: 100%;
float: left;
background-color:black;
}
#leftnav{
word-break:keep-all;
font-size: 1.5em;
position: relative;
left:10%;
top: 40%;
font-family:Rockwell Extra Bold, Georgia, "Times New Roman", Times, serif
}
#headertwo{
width: 30%;
height: 100%;
float: left;
}
#headerthree{
width: 35%;
height: 100%;
float: left;
background-color:green;
}
I appreciate any help.

Related

Adjusting image size using HTML and CSS

Hello I have made a website where my header adjusts to the size of the screen, but the contents inside the header are not adjusting. For instance, there is an image that is unable to adjust itself and ends up leaving the header to go under it once the browser window is resized. Font is also not adjusting.
I have already tried min-width and max-width but it is not working. I am using #media queries and was wondering if there is someway to use this query to make the contents inside the header to adjust themselves along with the header.
My <header> style is as follows:
header {
position: relative;
width: Auto;
height: 239px;
background: #FED93F;
}
Edit
What I have done is added a <header> tag and placed two images, along with a heading inside it. In the heading, the text does not adjust it self. In the image, the first image is a logo and the second is an image on the far right. The logo is placed somewhere at the left, with the text in the middle of it all.
<header>
<img src="images/Logo_image.png" style="margin-left:50px; margin-top:50px"/>
<h1>Company name</h1>
<p>Tag Line</p>
<img src="images/side_image.png" style="position: relative; align: right; float:right" />
</header>
When all this stuff is added, I want it to adjust itself to the size of the window just as the main header does. But it is not being so.
The CSS of the Text:
header h1
{
font-family: "Arial";
font-size: 72px;
color: #6A1111;
position: absolute;
left: 212px;
top: 78px;
}
header p
{
font-family: "Myriad Pro";
font-size: 21px;
color: #404041;
position:absolute;
margin: -35px 0 0 250px;
}
Try this:
header {
position:relative;
width: 100%;
height:239px;
background:#FED93F;
}
header img {
width: 100%;
height: auto;
}
The element inside your header should be 100% wide.
You should try like this -
header img {
max-width: 100%;
}
I hope it will helps you.
header {
position:relative;
width: 100%;
height:239px;
background:#FED93F;
}
header img {
width: 100px; /*Need give fixed width */
height: auto;
}

Image behind the link

So I have a menu and on it there is a button with text and I want behind the text to be an image that shows that you are on the page and this is the code:
HTML:
<div id="menu">
<div id="about">About Us</div>
</div>
CSS:
a {
text-decoration:none;
color: white;
background: url(images/hover.png);
width: 100%;
height: 38px;
}
#about {
background: url(images/button.png);
width: 168px;
height: 51px;
font-family: Anivers;
font-size: 20pt;
text-align: center;
color: white;
line-height: 50px;
vertical-align: middle;
margin-top: 1%;
}
So far, so good, except that the image will only show the height and width that coresponds to the size of the text. For instance if I make the text 24pt, the image behind it will grow larger, but if I make it smaller, the image will become smaller and I don't want that. So how do I stop it from happening. I already searched all over the place, sadly I couldn't find similar topic. I hope you can help me :).
If I understand your question correctly you need to add display: block to the <a> element and set height: auto; instead. As for the image it should not scale anymore and I centered an image for demo purposes.
DEMO
You can accomplish this by displaying your "a" element as a "block". This will allow you to specify the size of the element independent from the size of the font. You can then inherit the width and height of the "#about" css styling if that's the size of "hover.png", or specify your own size based on the actual size of "hover.png" if its different than that stated in "#about", it sounds like 38px for hover.png is what you want as opposed to the 51px height of the #about parent. Without setting "a" as a block, the font size of the text in "#about", the parent element, would rule the overall size of the a element and styling, and your background "images/hover.png" will only provide a background for that size.
Here's what your a element in css would look like with the 38px height, you could also say "inherit" for the height if desired. I tested this and it works:
a {
text-decoration:none;
color: white;
background: url(images/hover.png);
display: block;
width: inherit;
height: 38px;
}
I hope this helps.
<div id="menu">
<img src="images/4.png" />
About Us
</div>
#menu {
position: relative;
width: 168px;
height: 51px;
}
img {
width: 100%;
height: auto;
}
img:hover {
background: blue;
}
a {
position: absolute;
z-index: 100;
/* top: 0; PLACE LINK CORRESPOMNDING TO IMG
left: 0; PLACE LINK CORRESPOMNDING TO IMG */
background: red;
font-family: Anivers;
font-size: 23pt;
color: white;
line-height: 1.2;
}

Evenly space images in div using percentages

I need to space four images aligned horizontally evenly in a row. I am aware that this has been asked many times here, yet none of the solutions I found have worked for me. They all seem to rely on either a fixed width for the row, or a fixed width for the images. I need to specify both in percentages.
My Html:
<div id="tabBar">
<div id="PDiv">
<img id="Person" src="images/icons/tabBar/image0.png">
</div>
<div id="SDiv">
<img id="Sale" src="images/icons/tabBar/image1.png">
</div>
<div id="CtDiv">
<img id="Current" src="images/icons/tabBar/image2.png">
</div>
<div id="FDiv">
<img id="Food" src="images/icons/tabBar/image3.png">
</div>
<span id="Stretch"></span>
</div>
The CSS
#tabBar
{
position: fixed;
bottom: 0;
left: 0;
background-color: #F3F3F3;
width: 100%;
text-align: justify;
}
#PDiv, #SDiv, #CDiv, #FDiv
{
background-color: #F3F3F3;
width: 24%;
vertical-align: top;
height: auto;
display: inline-block;
}
#Stretch
{
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0;
}
The issue with this method is that I am building a mobile hybrid app. Therefore, it will have to work on many screen sizes. Currently it looks great on larger screens and computers, but on phones with smaller-sized screens, either the images begin to get cut off, or one of them goes and makes a new line. Instead, I need the images to just scale down and stay evenly spaced.
Have you tried scaling your images with CSS, like so:
img {
width: 100%;
height: auto;
}
This will prevent you images of creating new lines, or being cut off.
EDIT:
jsfiddle link: http://jsfiddle.net/ATube/
You have a mismatch in your CSS classes (#CtDiv vs #CDiv). This leaves CDiv as a block element.
If I may suggest though... the whole 'stretch' thing is unnecessary and the 24% just puts you into rounding errors. I'd recommend something more like this:
HTML
<div id="tabBar">
<div id="PDiv"></div>
<div id="SDiv"></div>
<div id="CDiv"></div>
<div id="FDiv"></div>
</div>
CSS
#tabBar {
position: fixed;
bottom: 0;
left: 0;
background-color: #F3F3F3;
width: 100%;
height:40px;
}
#PDiv, #SDiv, #CDiv, #FDiv {
background-color:#F3F3F3;
background-size:contain;
background-repeat: no-repeat;
background-position:center center;
width: 25%;
vertical-align: top;
display: inline-block;
float:left;
height:100%;
}
#PDiv {
background-image:url(images/icons/tabBar/image0.png);
}
#SDiv {
background-image:url(images/icons/tabBar/image1.png);
}
#CDiv {
background-image:url(images/icons/tabBar/image2.png);
}
#FDiv {
background-image:url(images/icons/tabBar/image3.png);
}
Generally, this should be somewhat lighter weight, but more importantly... allow you better separation of style and structure.
Even made you a fiddle:
http://jsfiddle.net/F6khC/

Clear Footer to Prevent Content Overlap

I've found a method of placing the footer that I like, except for the fact that footer overlaps the content when the page resizes.
Using the structure and formatting I have already, how can I "clear" the footer, so that it drops off when the page resizes (avoiding an overlap of #content)?
I've tried clear: left and that does nothing for this.
Essentially, I want the footer to always be visible, and attached to the lower left of the window, as long as space allows; however, when the window gets smaller, I don't want the footer to overlap my content.
CSS:
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
background-size: cover;
margin: 0;
height: 100%;
}
#wrapper {
min-height: 100%;
height: 100%;
min-width: 900px;
overflow: hidden;
}
.main_nav {
margin: 0;
width: 160px;
float: left;
padding-left: 40px;
overflow: hidden;
}
#content {
float: left;
width: 750px;
height: 600px;
}
#footer {
position: absolute;
bottom: 0px;
width: 100%;
height: 50px;
}
HTML:
<body>
<div id="wrapper">
<div id="header">
<h1></h1>
<ul class="main_nav">
<li></li>
</ul>
</div>
<div id="content">
</div>
</div>
<div id="footer">
<div id="footer_content"></div>
</div>
</body>
The answer has been already choosen, but i wanted to give an alternative.
The "wrapper" contains "header" and "content", while the "footer" is outside of it. You could, for example, add
z-index:10;
to the wrapper's css and
z-index:1;
to the footer's css.
This one last isn't really needed, but it's for completeness. This way, whenever they get in "touch", the one with higher z-index will remain on foreground (ie, higher level on the z-axis, that is the axis perpendicular to the screen surface) and the other elements will slide behind, according to their own index.
This problem is because of width. You width is different in each case i.e. in content , footer & wrapper as well. I created a jsfiddle
[http://jsfiddle.net/jvaibhav/xncuF/37/]
try this.

Div background image & height not working

I have a div main that I have wrapped around my content and a sidebar. I have assigned the #main to have a background image and a min-height of 1200px.
In Google Chrome & Firefox, when I inspect the div doesn't have any properties when I inspect the source. Thus the div's background image and height don't work either.
<!--Main content layout -->
#main {
clear:both;
position: relative;
min-height: 1200px;
background-image:url(images/white.png);
background-repeat: repeat-x;
}
.sidebar1 {
float: right;
width: 20%;
padding-bottom: 10px;
margin-top: 20px;
}
.content {
padding: 10px 0;
width: 76%;
float: left;
margin-top: 20px;
}
The site address is: http://www.tibetskyvillage.org/
Would really appreciate someone elses eyes on this. I use this method all the time and for some reason this time it's failing.
The comment <!--Main content layout --> is not a valid CSS comment but an HTML comment instead causing a parse error.
See the screenshot, I have found some disturbances in your layout, to fix this or solution to your problem is
Don't give the image as background in CSS, give it as image in html like this
<img width="1360" height="675" src="images/bg0.jpg" class="wraper">
<div id="main">Your content</div>
Add styles to the image and main as
.wraper {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
}
#main{
position: absolute;
min-height: 1200px;
width:100%;
}