Text centered but not responsive - html

In my Responsive website, the Headr text is not responsive compare to the page. As in my screenshot below:
Here is the relevant code I use:
html, body {
margin: 0 auto;
padding: 0;
}
.container {
max-width: auto;
margin: 0 auto;
width:100%;
}
.box {
border: 2px white dotted;
border-radius: 15px;
margin-top: 30px;
width: 380px;
padding: 10px;
left: 0;
right: 0;
margin-right:auto;
margin-left:auto;
position:absolute;
display:table-cell;
vertical-align:middle;
}
.nav-pills li a {
color: black;
border-radius: 10px;
margin: 3px;
font-size: 15px;
font-weight: 589px;
border-radius:0px;
background-color: white;
margin-top:260px;
}
.nav-pills li a:hover {
color: white;
background-color: transparent;
display:inline-block;
border: 1px white solid;
font-weight: 300;
}
.box h2 {
font: 70px/1.2 'Pacifico', Helvetica, sans-serif;
color: white;
text-shadow: 2px 2px 0px rgba(0,0,0,0.2), 4px 4px 8px rgba(0,0,0,0.2);
padding-right: 5px;
padding-left: 5px;
margin-left: 15px;
}
.box span {
margin-left: 70px;
}
.nav-pills {
display:table;
margin:0 auto;
position:relative;
}
/* centered columns styles */
.row-centered {
text-align:center;
}
.col-centered {
display:inline-block;
float:none;
/* reset the text-align */
text-align:left;
/* inline-block space fix */
margin-right:-4px;
}
<div class="header" id="header">
<div class="container">
<div class="row row-centered">
<div class="col-md-6 col-centered">
<div class="box">
<h2>Lewis <br><span>Designs</span></h2>
</div>
</div>
</div>
<div class="menu">
<div class="row row-centered">
<div class="col-md-6 col-centered">
<ul class="nav nav-pills">
<li>About</li>
<li>Consultations</li>
<li>Gallery</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
Very new to this, been getting help with centering in a previous question.
My only problem now, is that my header box is no longer responsive when i shrink my screen. I wonder what I did wrong.

It looks like all you need to do is define a width on the .col-centered class, because you defined the nested .box class with postion:absolute, which would set the position in reference to the parent element. Since the parent element had no width and was centered in its own parent element, the header box was positioned with that as the left reference point and extending 380px from there. You can read more about the CSS box model and how it works here.
.col-centered {
display:inline-block;
float:none;
width:100%;
/* reset the text-align */
text-align:left;
/* inline-block space fix */
margin-right:-4px;
}
See fiddle.

Related

can't get rid of list items height in menu

hi i just wanted to code a site like BBC just for practice while doing this i got an error in li item of a ul i don't know the problem but when i give it a border-right the border take more height then the original menu, i'm pasting my code here please check it and help me??
in simple words i want list item's border to be equal to the borders of "Signin" and "logo" div
<html>
<head>
<title>BBC</title>
<style>
body{
margin:0;
font-family:Arial,Helvetica,freesans,sans-serif;
}
#top{
width:100%;
height:50px;
}
.keepcenter{
width:1100px;
margin: 0 auto;
}
#logo{
border-right:1px solid #CCCCCC;
float:left;
padding-right:5px;
height:100%;
}
#signin{
font-weight:bold;
font-size:0.9em;
border-right:1px solid #CCCCCC;
width:200px;
height:100%;
float:left;
}
#signin img{
position:relative;
top:5px;
margin-left:15px;
}
#signin p{
display:inline;
position:relative;
top:1px;
padding-left:5px;
}
#menutop{
float:left;
}
#menutop ul{
list-style-type:none;
margin:0;
padding:0;
}
#menutop li{
padding:15px 20px 10px 20px;
display:inline;
font-weight:bold;
font-size:0.9em;
float:left;
border-right:1px solid #CCCCCC;
height:100%;
}
</style>
</head>
<body>
<div id="container">
<div id="top">
<div class="keepcenter">
<div id="logo">
<img src="images/logo.jpg" />
</div>
<div id="signin">
<img src="images/signicon.png" /><p>Sign In</p>
</div>
<div id="menutop">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
Simply remove the top and bottom padding from the list items.
body {
margin: 0;
font-family: Arial, Helvetica, freesans, sans-serif;
}
#top {
width: 100%;
height: 50px;
}
.keepcenter {
width: 1100px;
margin: 0 auto;
}
#logo {
border-right: 1px solid #CCCCCC;
float: left;
padding-right: 5px;
height: 100%;
}
#signin {
font-weight: bold;
font-size: 0.9em;
border-right: 1px solid #CCCCCC;
width: 200px;
height: 100%;
float: left;
}
#signin img {
position: relative;
top: 5px;
margin-left: 15px;
}
#signin p {
display: inline;
position: relative;
top: 1px;
padding-left: 5px;
}
#menutop {
float: left;
}
#menutop ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#menutop li {
padding: 0 20px;
display: inline;
font-weight: bold;
font-size: 0.9em;
float: left;
border-right: 1px solid #CCCCCC;
height: 100%;
}
<div id="container">
<div id="top">
<div class="keepcenter">
<div id="logo">
<img src="http://lorempixel.com/40/40" alt="BBC" />
</div>
<div id="signin">
<img src="http://lorempixel.com/g/10/10" alt="" />
<p>Sign In</p>
</div>
<div id="menutop">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
</div>
</div>
</div>
The list is floating though, which means that its baseline is not necessarily the same as the #signin div. In my snippet, the img in the div is small enough to not have an effect, but depending on its size, the baseline of the div (and therefore the position of the p) will move down. You may have to compensate for that in the ul.

CSS right border not fitting right

I'm just learning CSS and HTML and decided to have a go at making a mock up website. I'm having trouble with the border not meeting the end of the top bar. Other times I've had it go over.
https://jsfiddle.net/9gonuvu7/
#topnav li {
float: left;
margin: 0;
padding: 16px 10px 10px 20px;
list-style: none;
color: white;
font-size: 1.2em;
border-right: solid #3E6F87 1px;
You can see this in the above link. If you could explain to me why this is happening and how I can avoid it in future I would be very grateful.
Remove the padding from the parent.
That's preventing it from reaching top.
#topbar {
background-color: #2A4F6E;
width: 100%;
height: 50px;
padding: 0px 0 0px 0;
margin: 0;
}
Okay, because you said you just started with HTML and CSS I changed a bit more in your code.
At the moment your fixedwith div has no impact on the code (maybe you use it in your full website).
You applied the background on the whole topbar, that HTML-wise also contains your menu points, assuming you only want your headline to have that blue background I swapped that property to the h1-tag.
With this change the borderlines are overlapped b the headline, which should do the job.
new JSFiddle
* {
margin:0;
padding:0;
}
body {
margin: 0;
font-family: arial, helvetica, sans-serif;
}
a {
text-decoration: none;
color: white;
}
a:hover {
text-decoration: underline;
}
#topbar {
float:left;
width:100%;
height:100%;
overflow:hidden;
}
#topbar h1 {
display: block;
width:100%;
height:100%;
background-color: #2A4F6E;
padding: 7px 50px 7px 40px;
margin: 0;
color: white;
float: left;
border-right: solid #3E6F87 1px;
}
#topnav {
float:left;
width:100%;
height:50px;
background:#ccc;
}
#topnav li {
float: left;
margin: 0;
padding: 16px 10px 10px 20px;
list-style: none;
color: white;
font-size: 1.2em;
border-right: solid #3E6F87 1px;
}
#topnav ul {
margin: 0;
padding: 0;
}
#topnav a:hover{
color: #A97437;
}
<body>
<div id="container">
<div id="topbar">
<div class="fixedwidth">
<h1>Neil's Tech Reviews</h1>
<div id="topnav">
<ul>
<li> Home</li>
<li> Reviews</li>
<li> Forum</li>
<li> Partners</li>
<li> About</li>
</ul>
</div>
</div>
</div>
</div>
</body>

I want to fix my footer to the bottom of my content (not screen) so that it is all in one div ? Any ideas?

I want to fix my footer at the bottom of my content so that when ever i add content it will just automatically adjust with it, Like this website here (http://www.matthamm.com/about)
Here is the Jsfiddle of what it more or less looks like now
http://jsfiddle.net/9L6Lh/
HTML:
Home
<p>This Website will be made using PHP</p>
<p>A Home Page</p>
<p>A Style Sheet</p>
</div>
</div>
</div>
</div>
<div id="footer_wrapper">
<div id="footer_inner_wrapper">
<div>
<p>©
<?php echo date( "Y"); ?>UR. All rights reserved. Andrew Byrne.</p>
</div>
</div>
</div>
CSS:
body {
margin: 10%;
min-width: 30%;
text-align: center;
background-attachment: fixed;
background-image:url(/img/mooning.png);
font-weight:bold;
color:#666666;
}
#main {
height: auto;
width:80%;
margin:auto;
text-align:left;
padding:15px;
font-family:'Roboto', sans-serif;
background-color:red;
box-shadow: -10px -10px 15px #888;
overflow:auto;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
-webkit-font-smoothing: antialiased;
}
.day3txt {
margin-top: 1%;
border-bottom: 3px solid #c7c7c7;
padding: 80px;
}
#footer_wrapper {
background-color: black;
}
#Contact-font li {
list-style: none;
}
#Contact-font li a {
border-bottom: 2px solid #336699;
}
#Contact-font li a:hover {
color: #E8110F;
opacity: 0.7;
}
/*banner */
#nav li {
margin-top: 0.25%;
white-space: nowrap;
list-style: none;
float:left
}
#nav li a {
font-size: 25px;
display: inline-block;
padding: 10px 10px;
text-decoration: none;
color: #E8110F;
}
#nav select {
display: none;
}
Since you have a paragraph inside the footer, the browser gave it some default style(There are default styles for every element). Use a CSS Reset like this:
*{
margin:0px;
padding:0px;
}
OR
Just add this to your style:
#footer_wrapper p{
margin:0px;
}
Just add overflow: hidden; to the footer and append some margin.
here is your fiddle with "connected" footer: http://jsfiddle.net/9L6Lh/1/
#footer_wrapper {
background-color: black;
margin: 0 46px;
overflow: hidden;
-webkit-border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
Add This only at the top in the css file so before body{}
*{margin:0; padding:0;}

responsive center logo header with side navigation

I am trying to create a responsive centered logo header with side navigation. because I want it to be responsive there are no fixed widths which makes it difficult to accomplish the centering (margin:auto). As the window becomes smaller I would like the li tags to sit on top of each other. I do not want to float left and float right the side navigations because I want them to be be attached to the sides of the logo not the sides of the window, with the same amount of space between logo and menu on left and right.
html:
<div id="header">
<div id="nav">
<div id="nav-inner">
<ul id="site_nav_1">
<li id="menu-item">
The Problem
</li>
<li id="menu-item">
Why Sanitize
</li>
</ul>
<div id="logo-nav">
<div id="logo"></div>
</div>
<ul id="site_nav_2">
<li id="menu-item">
About Us
<li id="menu-item">
Sanitize Now!
</li>
</ul>
</div>
</div>
</div>
http://jsfiddle.net/7PhJZ/74/
You need to use media queries and set different styles depending on breakpoints. I would suggest mobile first.
Very rough fiddle at http://jsfiddle.net/7CcjD/ - try changing the width of the Result box.
<div id="header">
<div class="menu-1">Menu 1</div>
<div class="logo">Logo</div>
<div class="menu-2">Menu 2</div>
</div>
div {border: 1px solid #999}
.menu-1 {border-color: red}
.logo {border-color: green}
.menu-2 {border-color: blue}
.menu-1, .logo, .menu-2 {
margin: 1em auto;
width: 80%
}
#header {text-align: center;}
#media only screen and (min-width: 640px) {
.menu-1, .logo, .menu-2 {
border-width: 2px;
width: 20%;
display: inline-block;
}
}
you could use inline-block instead floatting :
http://jsfiddle.net/7PhJZ/75/
#nav {
margin:auto;
display: block;
border: 1px solid green;
}
#nav-inner {
max-width:810px;
height:200px;
margin:auto;
display: block;
border: 1px solid grey;
white-space:nowrap;/* keep them on one line */
}
#header {
position: fixed !important;
overflow: visible;/* auto if fixed would be wised somehow */
padding: 0px;
width: 100%;
top: 0;
left:0;
border: 1px solid purple;
}
#logo-nav {
display: inline-block;
}
#logo {
border: 1px solid blue;
margin: 0px auto 0px auto;
width: 225px;
height: 124px;
}
ul#site_nav_1 {
display:inline-block;
border: 1px solid red;
text-align:right;
max-width:32%;
}
ul#site_nav_2 {
display:inline-block;
border: 1px solid red;
text-align:left;
max-width:29%;
}
li#menu-item {
display:inline-block;
padding:20px;
text-align: center;
}
a {
font-family:'gobold_boldregular';
font-size:25px;
text-transform:uppercase;
letter-spacing: 1px;
text-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);
}
/* some reset */
#logo-nav, #site_nav_1, #site_nav_2 {
vertical-align:middle;
}
ul, li {
padding:0;
margin:0;
white-space:normal;
}

two divs on each side on the same line

How can I make it stay on the same line? I want "How ya doin?" to be on the same line as the menu.
<div class="header">
<b>How ya doin?</b>
<ul class="menu">
<li>Home</li>
<li>Registration</li>
<li>Terms of Use</li>
<li>Support</li>
</ul>
</div>
THe CSS:
* { margin: 0; padding: 0; }
.header {
background: #CCC;
font-weight: bold;
padding: 5px 5px 3px 16px;
}
ul {
padding-left: 10px;
color: #444;
list-style: none;
margin: 0px 0px 5px 10px;
}
.menu {
font-weight: normal;
background: #CCC;
color: #000;
text-align: right;
}
.menu li {
display: inline;
margin-right: 8px;
}
This is what I get:
I'd give the b and the ul both a width, say 50% for making it easy, then float one right and one left.
You'll need a div to clear it afterwards to fix the layout though.
Something like:
.header b {
width:50%;
float:left;
}
.header ul {
width:50%;
float:right;
}
then underneath
<div style="clear:both"></div>
to avoid messing things up.
Try
ul {
display:inline;
/* ... */
}
something like:
.header b{display:block; width: 100px; float:left}
.menu {width:150px; float:left}
Good luck
what about using absolute / relative positions?
this is really a simple and nice solution for header text, easy to add another elements as well
.header{
position: relative;
}
.header > b{
position: absolute;
left: 10px;
top: 5px;
}
.header > ul{
position: absolute;
top: 5px;
right: 10px;
}
<div class="header">
<!-- float to left -->
<b style="float: left;">How ya doin?</b>
<!-- float to right, or you can add float to .menu in css -->
<ul style="float: right;" class="menu">
<li>Home</li>
<li>Registration</li>
<li>Terms of Use</li>
<li>Support</li>
</ul>
<!-- clearing float -->
<br style="clear:both;" />
</div>
I changed your CSS to this and it seemed to do the trick (additions noted):
* { margin: 0; padding: 0; }
.header {
background: #CCC;
font-weight: bold;
padding: 5px 5px 3px 16px;
float:left; /* ADDED */
width:100%; /* ADDED */
}
b {
float:left; /* ADDED */
}
ul {
padding-left: 10px;
color: #444;
list-style: none;
margin: 0px 0px 5px 10px;
}
.menu {
font-weight: normal;
background: #CCC;
color: #000;
text-align: right;
}
.menu li {
display: inline;
margin-right: 8px;
}
The ul is a block element, so by default it starts on a new line, taking 100% of the available width. You need to tell it to behave differently.
Easiest should be to set display: inline; on the ul element.
Another is to set float: left; on both the <b> and the <ul>, and give them both a width.
If you take the latter (float) approach, you'll need to tell .header to contain the floats. Easiest way to do that is height: 1%; overflow: hidden;.