As my title suggests, my content goes off screen.
I've looked through my css file, and there's isn't any margins with minus something. So why is the content going off screen at both sides?
Appreciate any suggestions to why this is.
Thanks.
body{
background: linear-gradient(rgb(100,50,50), rgb(80,20,20)) no-repeat;
color: white;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
img{
margin: 1%;
}
/*Header*/
header {
background-color: #1d1e21;
height: 100vh;
position: relative;
}
header span {
color: #fff;
}
header input {
margin-top: 20px;
}
p#slogan {
color: #fff;
letter-spacing: 2px;
}
ul {
list-style-type: none;
}
ul li {
display: inline;
padding: 0 0 0 10px;
}
ul li a {
color: #fff;
list-style-type: none;
}
ul li a:hover {
color: black;
list-style-type: none;
text-decoration: none;
}
/*Main*/
/*sloganAndSocial*/
#sloganAndSocial {
background-color: #1d1e21;
position: absolute;
bottom: 0px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>NBC 2011</title>
<link rel="stylesheet" href="css/main.css" type="text/css" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<script src="js/scripts.js" type="text/javascript"></script>
</head>
<body>
<!--Header section-->
<header>
<div id="topBar">
<div class="row">
<h1 class="pull-left"><span>NORDIC </span>BARISTACUP</h1>
<form class="pull-right">
<input type="text" name="search" placeholder="Search..">
</form>
</div>
<div class="row">
<p class="pull-left" id="slogan">be together act together learn together</p>
<ul class="pull-right">
<li>ABOUT NBV</li>
<li>2011 EVENT</li>
<li>NORDIC ROASTER</li>
<li>RESULTS</li>
<li>LINKS</li>
<li>CONTACT</li>
</ul>
</div>
</div>
<!--Main section-->
<div class="main">
<img src="" alt="bo!" class="cover" />
</div>
<div id="sloganAndSocial">
<div class="container">
<div class="row">
<h2 class="pull-left">"To create an environment in which knowledge<br>about coffee and its sphere can be obtained"</h2>
<ul class="share-buttons">
<li><img alt="Share on Facebook" src="images/flat_web_icon_set/inverted/Facebook.png"></li>
<li><img alt="Tweet" src="images/flat_web_icon_set/inverted/Twitter.png"></li>
<li><img alt="Share on Google+" src="images/flat_web_icon_set/inverted/Google+.png"></li>
<li><img alt="Pin it" src="images/flat_web_icon_set/inverted/Pinterest.png"></li>
<li><img alt="Send email" src="images/flat_web_icon_set/inverted/Email.png"></li>
</ul>
</div>
</div>
</div>
</header>
<!--Section1-->
</body>
</html>
You have two divs in your topBar with class row but which are not inside an element with class container. That is not intended by Bootstrap and therefore leads to unintended behaviour. You have to wrap those two divs in another div with class container.
Also, as #nik_m mentioned: Why are you wrapping the whole page in a header? That's not, what headers are supposed to do.
Remove pull-left and pull-right classes from the elements and better use flexbox for your alignments. It will make your life much easier!
Also, why the wrapper of the whole site is inside a header???
Related
I have a list that I am using as a horizontal timeline. However, I am having trouble trying to left align the list, so that the first element is flush left with left side of the scrollbar. I know part of the problem is that I have a set margin-left, I need some way to put space in between list elements (removing margin-left pushes the first element further to the left, but not all the way to be flush with the left side of the scrollbar.
.navbar {
margin-bottom:0px;
}
.jumbotron {
margin-bottom:0px;
}
#timeline {
list-style:none;
white-space:nowrap;
overflow:auto;
}
#timeline li {
display:inline-block;
padding:1.5%;
border:1px solid #d1d2d3;
margin-left:2%;
margin-bottom:2%;
margin-top:2%;
text-align:center;
}
#timeline li h3, #timeline li em {
display:block;
}
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet">
<link href="styles.css" rel = "stylesheet" type = "text/css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>LinkedIn</li>
</ul>
</div>
</nav>
<div class="jumbotron text-center">
<h1>My Name</h1>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>What I've Been Up To</h1>
</div>
</div>
<!--Timeline-->
<div class="row" style="overflow:auto">
<ul id="timeline">
<li>
<h3>Graduated from College</h3>
<em>May 24, 2012</em>
</li>
<li>
<h3>Started my first job</h3>
<em>June 30, 2012</em>
</li>
<li>
<h3>Started my second job</h3>
<em>April 3, 2014</em>
</li>
<li>
<h3>Bought a house!</h3>
<em>August 12, 2015</em>
</li>
<li>
<h3>Got married</h3>
<em>June 3, 2016</em>
</li>
<li>
<h3>First child born</h3>
<em>May 1, 2017</em>
</li>
</ul>
</div>
</div>
<footer>
<p> Copyright ©
<!--Script displays the current year-->
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
</p>
</footer>
</body>
</html>
You have everything there except you omitted padding-left:0px; in the timeline id!
Well done you, looks great!
.navbar {
margin-bottom: 0px;
}
.jumbotron {
margin-bottom: 0px;
}
#timeline {
list-style: none;
white-space: nowrap;
overflow: auto;
padding-left: 0px;
}
#timeline li {
display: inline-block;
padding: 1.5%;
border: 1px solid #d1d2d3;
margin-left: 2%;
margin-bottom: 2%;
margin-top: 2%;
text-align: center;
}
#timeline li h3,
#timeline li em {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>LinkedIn</li>
</ul>
</div>
</nav>
<div class="jumbotron text-center">
<h1>My Name</h1>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>What I've Been Up To</h1>
</div>
</div>
<!--Timeline-->
<div class="row" style="overflow:auto">
<ul id="timeline">
<li>
<h3>Graduated from College</h3>
<em>May 24, 2012</em>
</li>
<li>
<h3>Started my first job</h3>
<em>June 30, 2012</em>
</li>
<li>
<h3>Started my second job</h3>
<em>April 3, 2014</em>
</li>
<li>
<h3>Bought a house!</h3>
<em>August 12, 2015</em>
</li>
<li>
<h3>Got married</h3>
<em>June 3, 2016</em>
</li>
<li>
<h3>First child born</h3>
<em>May 1, 2017</em>
</li>
</ul>
</div>
</div>
<footer>
<p> Copyright ©
<!--Script displays the current year-->
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
</p>
</footer>
</body>
</html>
I would strongly suggest you learn how to use your Browser's developer console. A quick inspection of this revealed that the #timeline element has 40px of padding-left.
I removed that padding, and altered your margin-left on the timeline items so that it only puts margin between elements. I did this by using the adjacent sibling selector:
#timeline li + li {
margin-left: 2%;
}
And - as a side-note, 0px is redundant / not necessary, as 0 is unitless, you can simply use 0 in values (such as margin-bottom: 0;)
Here's your snippet, modified to work properly:
.navbar {
margin-bottom: 0;
}
.jumbotron {
margin-bottom: 0;
}
#timeline {
list-style: none;
white-space: nowrap;
overflow: auto;
padding-left: 0;
}
#timeline li {
display: inline-block;
padding: 1.5%;
border: 1px solid #d1d2d3;
margin-bottom: 2%;
margin-top: 2%;
text-align: center;
}
#timeline li + li {
margin-left: 2%;
}
#timeline li h3,
#timeline li em {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet">
<link href="styles.css" rel = "stylesheet" type = "text/css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>LinkedIn</li>
</ul>
</div>
</nav>
<div class="jumbotron text-center">
<h1>My Name</h1>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>What I've Been Up To</h1>
</div>
</div>
<!--Timeline-->
<div class="row" style="overflow:auto">
<ul id="timeline">
<li>
<h3>Graduated from College</h3>
<em>May 24, 2012</em>
</li>
<li>
<h3>Started my first job</h3>
<em>June 30, 2012</em>
</li>
<li>
<h3>Started my second job</h3>
<em>April 3, 2014</em>
</li>
<li>
<h3>Bought a house!</h3>
<em>August 12, 2015</em>
</li>
<li>
<h3>Got married</h3>
<em>June 3, 2016</em>
</li>
<li>
<h3>First child born</h3>
<em>May 1, 2017</em>
</li>
</ul>
</div>
</div>
<footer>
<p> Copyright ©
<!--Script displays the current year-->
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
</p>
</footer>
</body>
</html>
To get those Li's really stuck to the left hand-side of your element you need remove the padding and margin from the UL first, then on the Li's apply a margin-right rather than left.
#timeline {
list-style: none;
white-space: nowrap;
overflow: auto;
margin: 0;
padding: 0;
}
#timeline li {
display: inline-block;
padding: 1.5%;
border: 1px solid #d1d2d3;
margin-right: 2%;
margin-bottom: 2%;
margin-top: 2%;
text-align: center;
}
Part of your problem is the margin-left on the list element, yes. You can remove that for the first one like so: #timeline li:first-child { margin-left: 0; }. Additionally, the ul itself has padding to the left by default, which you can remove like so: #timeline { padding-left: 0; }.
You need to add in this to the css:
#timeline li:first-child {
margin-left:0
}
and change this css for the timeline element:
#timeline {
list-style:none;
white-space:nowrap;
overflow:auto;
padding: 0;
}
thats it!
I am trying to style a web page using css. For some reason my header does not spread over where the header should be, which means the width is not 100%. it looks like this now this is the screenshot
header {
width: 100%;
}
#logo_picture {
margin-left: 80px;
}
#logo img,
#logo nav {
float: left;
}
#logo nav {
line-height: 120px;
margin-left: 250px;
}
nav ul {
list-style: none;
margin: 0 10px;
padding: 0;
}
nav li {
display: inline;
}
nav a {
color: black;
font-size: 20px;
font-family: 'Arsenal', 'sans-serif';
font-weight: 300;
padding: 2px 38px;
text-decoration: none;
}
nav a,
nav a:visited {
color: black;
}
nav a.selected,
nav a:hover {
color: grey;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Larry Rosenburg Official Website</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Anton|Crimson+Text:400,700,700i|Rakkas" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Cherry+Swash|Cinzel|Gentium+Basic|Muli" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Arsenal" rel="stylesheet">
</head>
<body>
<header>
<div id="logo">
<img src="lincoln.jpg" width="30%" alt="Lincoln logo" id="logo_picture">
<nav>
<ul>
<li> Home
</li>
<li> Lincoln
</li>
<li> About
</li>
<li> Contact
</li>
</ul>
</nav>
</div>
</header>
<h1> Larry Rosenburg </h1>
<p>
I believe that as important as skills and experiences are in our professional careers, it is the relationships that we create which allow us to truly succeed. My company provides title insurance, settlement, escrow and exchange services on a level that
is second to none, but my focus is helping your succeed with your commercial and residential transactions. As a person who can deliver a full range of solutions, I am able to leverage the power of my company with my drive to be concerned with your
company.
</p>
<div id="profile-pic">
<img src="picture.jpg" width="35%" alt="">
</div>
</body>
<footer>
</footer>
</html>
After every float you must create a clear class. Try adding in the CSS:
.clearfix {
clear: both;
}
in the html after the </header> add <div class="clearfix">
I am trying to build a site (just to learn, is not an actual website) and at the top there's links to different sections of the page. The HTML goes as follows:
<!DOCTYPE html>
<html>
<head>
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet">
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="nav">
<div class="container">
<ul>
<li>Airbnb logo</li>
<li>Browse</li>
</ul>
<ul>
<li>Sign Up</li>
<li>Log In</li>
<li>Help</li>
</ul>
</div>
</div>
<div class="header">
<div class="container">
<h1>Find a place to stay.</h1>
<p>Rent from people in over 34,000 cities and 192 countries.</p>
</div>
</div>
<div class="learn-more">
<div>
<div>
<div>
<h3>Travel</h3>
<p>From apartments and rooms to treehouses and boats: stay in unique spaces in 192 countries.</p>
<p>See how to travel on Airbnb</p>
</div>
<div>
<h3>Host</h3>
<p>Renting out your unused space could pay your bills or fund your next vacation.</p>
<p>Learn more about hosting</p>
</div>
<div>
<h3>Trust and Safety</h3>
<p>From Verified ID to our worldwide customer support team, we've got your back.</p>
<p>Learn about trust at Airbnb</p>
</div>
</div>
</div>
</div>
</body>
</html>
Now I am trying to style the page, but I want all the elements of the navbar in the same line.
So far I have:
.nav a {
color: #5a5a5a;
font-size: 11px;
font-weight: bold;
padding: 14px 10px;
text-transform: uppercase;
}
.nav li {
display: inline;
}
.header {
background-image:url('http://bit.ly/1KIFZoI');
background-size: cover;
height: 300px;
}
.header h1 {
color: #fff;
font-size: 48px;
font-family: 'Shift', sans-serif;
font-weight: bold;
}
.header p {
font-size: 20px;
color: #fff;
}
However, the display: inline; still leaves my navbar in two lines. I want them all in the same line if possible not putting all the elements in the same list (same ul)
Thanks!
Just do this:
ul{
display: inline-block;
vertical-align: middle;
}
Beware: you have default padding in the <ul>, because of that you
have a gap between them. Just add padding:0 and/or margin:0to the
<ul> to eliminate the gap ( adjust your needs ).
DEMO HERE
I've been trying to figure this out for a while but I can't seem to get it to work. All I want is to add text in the middle of the list item (see code) however it creates an extra line and makes the row bigger. I tried using the tag but it doesn't work. How can I add the text to be centered without changing the row size?
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<style>
.ui-icon-myicon:after {
background-image: url("http://people.mozilla.org/~shorlander/files/australis-linux-svg-test/images-linux/toolbarButton-bookmark.svg");
}
.ui-icon-myicon2:after {
background-image: url("http://forum.librecad.org/images/gear.png");
}
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
</style>
<div data-role="page" id="page1">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true" >
<li data-icon="myicon"><span class="ui-icon-myicon2 ui-btn-icon-notext inlineIcon"></span>Center this text</li>
</ul>
</div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<h1>My page footer</h1>
</div>
</div>
</html>
There is a better solution than adding spans. Copy jQuery Mobile button's CSS, that are used for icons. Do the changes you want to them. Of course, add a custom class to a tag.
See it working here.
<li>
Center Text
</li>
jQuery Mobile uses :after, use :before for your left side icon.
.ui-icon-myicon:before {
content:"";
left: .5625em;
position: absolute;
display: block;
width: 22px;
height: 22px;
background-color: #666;
background-color: rgba(0, 0, 0, .3);
background-position: center center;
background-repeat: no-repeat;
-webkit-border-radius: 1em;
border-radius: 1em;
background-image: url("http://forum.librecad.org/images/gear.png");
}
To center text, follow CSS hierarchy to override default settings.
Thanks to ezanker for his valuable input. Adding padding: 40px makes center alignment just perfect!
.ui-listview > li > a.ui-btn {
text-align: center;
padding: 40px; /* see ezanker's comment below */
}
Use text-align: center to center align the text.
Set the extra icon to display: block and use the ui-btn-icon-left class to align left.
li.x-center > a.ui-btn {
text-align: center;
}
li.x-center > a > span {
display: block;
}
<ul data-role="listview" data-inset="true">
<li data-icon="myicon" class="x-center">
<span class="ui-btn-icon-left ui-icon-myicon2"></span>Center this text
</li>
</ul>
Fiddle
Add style="text-align:center" to your <a> tag:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<style>
.ui-icon-myicon:after {
background-image: url("http://people.mozilla.org/~shorlander/files/australis-linux-svg-test/images-linux/toolbarButton-bookmark.svg");
}
.ui-icon-myicon2:after {
background-image: url("http://forum.librecad.org/images/gear.png");
}
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
</style>
<div data-role="page" id="page1">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true" >
<li data-icon="myicon"><span class="ui-icon-myicon2 ui-btn-icon-notext inlineIcon"></span>Center this text</li>
</ul>
</div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<h1>My page footer</h1>
</div>
index.html and style.css are on my local machine to practice coding.
Chrome and Safari are rendering the CSS correctly but FireFox 29 is not. Firefox recognize the css file but it's not rendering it. I've tried on a different machine and still have the same issue.
I've already validated my code and there were no errors. Am I missing any tag that is preventing this from rendering in Firefox?
<!DOCTYPE html>
<html>
<head>
<meta charset= "utf-8">
<link rel="stylesheet" type="test/css" href="style.css">
<title>Welcome!</title>
</head>
<body>
<div id="pagewrap">
<!-- Top Head of My Page -->
<div id="header">
<nav id="nav">
<div id="socialnetwork">
<img src="./Social_Icons/Linkedin.png" alt="LinkedIn">
<img src="./Social_Icons/facebook.png" alt="FB">
<img src="./Social_Icons/Instagram.png" alt="InstaGram">
<img src="./Social_Icons/Twitter.png" alt="Twitter">
<img src="./Social_Icons/Skype.png" alt="Yelp">
<!-- Icons from Dribble by Dawid Dapszus https://dribbble.com/dashoo-->
</div>
<!-- End of Social Network Links-->
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Resume</li>
<li>About Me</li>
<li>Contact </li>
</ul>
</nav>
</div>
</div>
<!--End of Page Wrap -->
</body>
</html>
body {
font-family:'Century Gothic', sans-serif;
}
a {
text-decoration: none;
}
#pagewrap {
width:950px;
margin: 0 auto;
}
#socialnetwork {
padding-top: 100px;
float:right;
}
#socialnetwork img{
height:30px;
}
#nav ul{
text-align: left;
border-bottom: groove;
}
#nav li{
margin:0 15px 0 0;
display: inline;
}
#nav li a:link{
color:#868686;
}
#nav li a:visited{
color:#868686;
}
#nav li a:hover{
color:#324EDC;
}
#nav li a:active{
color:#324EDC;
}
You are typing the wrong word in Link tag attribute value, you are typing "test/css" instead of "text/css"
Your Tag:
<link rel="stylesheet" type="test/css" href="style.css">
Updated Tag:
<link rel="stylesheet" type="text/css" href="style.css">
type="test/css"
Shouldn't it be: text/css?