I'm so new to coding and for school we need to code a website. Right now I'm slowly rolling into it, but I can't get my navigation and title to center. On my 13 inch laptop it all looks fine, but on a bigger pc it isn't centered anymore.
This is the link to the website, it's a mess right now: http://st358373.cmd16c.cmi.hanze.nl/portfolio.html
Updated question:
How do I get my title and subtitle centered?
HTML code:
<div class="titel">Portfolio</div>
<div class="subtitel">Hier is een selectie van recentelijk werk.</div>
CSS:
.titel {
font-family: Raleway;
font-size: 52px;
color: #3b3d40;
text-align: center;
font-weight: 700;
margin-top: 20px;
}
.subtitel {
font-family: Adobe Caslon Pro;
font-size: 18px;
text-align: center;
margin-top: 40px;
margin-bottom: 50px;
}
One way would be:
ul.topnav li {
/* float: left; Remove this. */
display: inline-block;
}
ul.topnav {
text-align: center;
}
.titel {
font-family: Raleway;
font-size: 52px;
color: #3b3d40;
font-weight: 700;
text-align: center;
margin-top: 20px;
width: 100%;
}
ul.topnav {
list-style-type: none;
margin: 0;
overflow: hidden;
font-family: Raleway;
font-weight: 500;
/* float: center; */
text-align: center;
position: center center;
}
ul.topnav li {
/* float: left; */
display: inline-block;
}
ul.topnav li a {
display: inline-block;
color: #3b3d40;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 10px;
letter-spacing: 2px;
}
ul.topnav li a:hover {
background-color: #555;
}
ul.topnav li.icon {
display: none;
}
<ul class="topnav" id="myTopnav">
<li>HOME
</li>
<li>PORTFOLIO
<div style="margin-top:-12px;border-bottom:1px solid #3b3d40;height:1px;"></div>
</li>
<li>BLOG
</li>
<li>PROJECTEN
</li>
<li>ONTWERPPROCES
</li>
<li>VERANTWOORDING
</li>
<li>OVER
</li>
<li>CONTACT
</li>
<li class="icon">
☰
</li>
</ul>
<div class="titel">Portfolio</div>
Use flex. The invisible item and the right div should have same width. You can add some content in invisible div and remove visibility:hidden;
.header{
height:60px;
background-color:green;
display:flex;
flex-direction:row;
align-items:center;
}
.header>div:first-child {
margin-right: auto;
visibility: hidden;
width:100px;
}
.header .navigation{
height:50px;
margin:0;
text-align:center;
color:white;
}
.header .right{
margin:0;
padding:0;
margin-left:auto;
width:100px;
}
.header .right img{
width:30px;
margin:0 5px;float:right;
}
<div class="header">
<div>invisible</div>
<div class="navigation">Navigation Bar</div>
<div class="right">
<img src="http://www.chinabuddhismencyclopedia.com/en/images/thumb/b/b8/Nature.jpg/240px-Nature.jpg"/>
<img src="http://images.financialexpress.com/2015/12/Lead-image.jpg"/>
</div>
</div>
Related
I am trying to build a heading/nav bar and want to know the best way to build it. I feel like I wrote too much code and made it way more complicated than should be. I wasn't too sure how to change the space between the heading and menu. When I resize the window the menu text gets messed up.
body {
padding: 0;
margin: 0;
box-sizing: border-box;
}
#navbar {
width: 100%;
height: 10%;
position: fixed;
display: flex;
align-items: center;
background-color: #cae7df;
border-bottom: 1px solid black;
}
#heading {
font-family: comic sans ms;
font-size: 1.5rem;
width: 50%;
margin-left: 5%;
}
.sections {
font-family: comic sans ms;
font-size: 1rem;
}
#menu {
display: flex;
justify-content: space-between;
align-items: center;
width: 50%;
margin-right: 5%;
}
<div id="navbar">
<h1 id="heading">The Arena</h1>
<div id="menu">
<h2 class="sections">Games</h2>
<h2 class="sections">How Tt Works</h2>
<h2 class="sections">Team</h2>
</div>
You shouldn't use h2 tags in a navigation
It should be something like this:
.nav{
float:right;
}
.nav_list{
list-style:none;
padding:0;
margin:0;
}
.nav_item{
display: inline-block;
}
.nav_item a{
padding: 5px 15px;
background: #eee;
text-decoration: none;
color: #444;
}
.nav_item a:hover{
background: #E1ECF4;
color: blue;
}
<div class="nav">
<ul class="nav_list">
<li class="nav_item">
Some Link
</li>
<li class="nav_item">
Some Link
</li>
<li class="nav_item">
Some Link
</li>
</ul>
</div>
So for one of my school projects, we have to design a website using Html & CSS and I've encountered a problem where I don't know how to fit 2 logos (left & right) into the corners of my footer. I've tried to change the position, float, width etc and it doesn't seem to work, the logo always seems to not go in the place I want it to be. Sorry if this sounds amateur as I've only started doing Html & CSS a few weeks ago.
This is the current image where the logo is below my ul's and is in the incorrect position. -
This is what I want the footer to look like, it would be great to have the text on the left "Sponsored by HP omen gaming" to be a image as I may swap it out with another logo in the future. -
Thanks to anyone in advance who may be able to solve this problem for me, below would be my html & CSS code.
.footer {
background-color: #035642;
margin-top: 10px;
height: 60px;
color: #efe5d0;
text-align: center;
padding: 15px;
font-size: 100%;
font-family: Arial;
display: block;
}
.footer ul {
padding: 5px;
list-style-type: none;
text-align: center;
margin: 10px;
overflow: hidden;
}
.footer li {
text-decoration: none;
text-align: center;
font-family: arial;
font-weight: bold;
list-style-type: none;
display: inline-block;
}
.footer ul li {
display: inline-block;
}
.footer ul li a {
text-decoration: none;
padding: .2em 1em;
color: #efe5d0;
background-color: #5c755e;
text-align: center;
font-family: arial;
font-weight: bold;
}
.footer ul li a:hover {
color: #000;
background-color: #fff;
}
#footer-right {
height: 50px;
width: auto;
position: fixed;
float: right;
}
<div class="footer">
<li>WBHS ESPORTS</li>
<ul>
<li>Facebook</li>
<li>|</li>
<li>YouTube</li>
<li>|</li>
<li>Twitch</li>
</ul>
<img src="hp-omen-logo.png" id="footer-right">
</div>
Try look into flexbox. Here's a quick template to do what you want.
.footer {
display: flex;
justify-content: space-between;
}
.center {
text-align: center;
}
<div class="footer">
<p>Left</p>
<div class="center">
<p>Some text</p>
<p>Your list</p>
</div>
<p>Right</p>
</div>
I think a solution can be the use of display:flex
And to be more clean try to use also the widgets, you can see in this example how it works.
.footer {
background-color: #035642;
margin-top: 10px;
height: 60px;
color: #efe5d0;
text-align: center;
padding: 15px;
font-size: 100%;
font-family: Arial;
display: block;
}
.footer ul {
padding: 5px;
list-style-type: none;
text-align: center;
margin: 10px;
overflow: hidden;
}
.footer li {
text-decoration: none;
text-align: center;
font-family: arial;
font-weight: bold;
list-style-type: none;
display: inline-block;
}
.footer ul li {
display: inline-block;
}
.footer ul li a {
text-decoration: none;
padding: .2em 1em;
color: #efe5d0;
background-color: #5c755e;
text-align: center;
font-family: arial;
font-weight: bold;
}
.footer ul li a:hover {
color: #000;
background-color: #fff;
}
#footer-right {
height: 50px;
width: auto;
position: fixed;
float: right;
}
/*my-edit*/
#the-footer{
display:flex;
flex-wrap:wrap;
justify-content:space-between;
align-items:center;
height: auto;
margin: 0;
padding: 10px;
}
#the-footer .widget{
width: 30%;
}
#the-footer .widget.left{
text-align: left;
}
#the-footer .widget.right{
text-align: right;
}
#the-footer .widget.center{
text-align: center;
}
#the-footer .widget .title{
font-weight: bold;
letter-spacing: 2px;
}
#the-footer .widget .logo-link{
color:#fff;
display: inline-block;
text-decoration: none;
max-width:150px;
}
#the-footer .widget .logo-link:hover{
color:#000;
}
<div class="footer" id="the-footer">
<div class="widget left">
<a class="logo-link" href="#" target="_blank">Sponsored by HP omen gaming</a>
</div>
<div class="widget center">
<div class="title">WBHS ESPORTS</div>
<ul class="footer-nav">
<li>Facebook</li>
<li>|</li>
<li>YouTube</li>
<li>|</li>
<li>Twitch</li>
</ul>
</div>
<div class="widget right">
<a class="logo-link" href="#" target="_blank"><img class="logo-footer" src="https://via.placeholder.com/60" alt="logo"></a>
</div>
</div>
You can use the display: grid property so you can separate your footer into 3 parts
You can learn about the grid property here: https://www.w3schools.com/css/css_grid.asp
Hi guys i am trying to put my images in the middle of the screen using flex box and then adding some padding between each one. However for some reason the first image overlaps the second image and i am trying to sort it out:
As you can see here i got it to work with fa icons which is perfect: Link here
HTML:
<div class="row">
<div class="col-md-12">
<div class="sidebar-social">
<ul>
<li>
<a id="header1" rel="nofollow" target="_blank" title="Facebook"><img src="Images/phone1.png">
<span id="header1span">Reklambyrå</span>
</a>
</li>
<li>
<a id="header1" rel="nofollow" target="_blank" title="Facebook"><img src="Images/phone.png">
<span id="header1span">Reklambyrå</span>
</a>
</li>
</ul>
</div>
</div>
</div>
CSS:
.services .get_in {
margin: 0;
}
.sidebar-social {
margin: 0;
padding: 0;
}
.sidebar-social ul {
margin: 0;
padding: 5px;
display: flex;
align-items: center;
justify-content: center;
}
.sidebar-social li {
text-align: center;
width: 15.9%;
margin-bottom: 3px!important;
background-color: #fff;
display: inline-block;
font-size: 10px;
padding:0;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.sidebar-social i {
display: block;
margin: 0 auto 10px auto;
width: 32px;
height: 32px;
margin: 10px auto 0;
line-height: 32px;
text-align: center;
font-size: 20px;
color: #383533;
margin-top:0;
padding-top:5px;
}
.sidebar-social a{
text-decoration:none;
width:100%;
height:100%;
display:block;
margin:0;
padding:0;
}
.sidebar-social a span{
color:black;
font-size:10px;
padding:5px 0 10px 0;
display:block;
text-transform:uppercase;
font-family:'Josefin Sans';
letter-spacing:1px;
}
.sidebar-social a:hover i.fa-paint-brush { color: #FFC600; }
.sidebar-social a:hover i.fa-phone { color:#FFC600 }
However now i want it to get to work with actual pictures, i want the same layout but using my pictures instead of the icons, but when i do it, it overlaps completely , So just simply how can i get there to be padding between each div so i can insert photos instead of icons
Thanks
Check out this code, I added width 100% to the anchor tag.. you had a width of 16.some % and your image was wider than than the container width and thats you it was overlapping.
.services .get_in {
margin: 0;
}
.sidebar-social {
margin: 0;
padding: 0;
}
.sidebar-social ul {
margin: 0;
padding: 5px;
display: flex;
align-items: center;
justify-content: center;
}
.sidebar-social li {
text-align: center;
width: 100%;
margin-bottom: 3px!important;
background-color: #fff;
display: inline-block;
font-size: 10px;
padding:0;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
//background-image: url('//www.fillmurray.com/500/1200');
}
.sidebar-social i {
display: block;
margin: 0 auto 10px auto;
width: 32px;
height: 32px;
margin: 10px auto 0;
line-height: 32px;
text-align: center;
font-size: 20px;
color: #383533;
margin-top:0;
padding-top:5px;
}
.sidebar-social a{
text-decoration:none;
width:100%;
height:100%;
display:block;
margin:0;
padding:0;
}
.sidebar-social a span{
color:black;
font-size:10px;
padding:5px 0 10px 0;
display:block;
text-transform:uppercase;
font-family:'Josefin Sans';
letter-spacing:1px;
}
.sidebar-social a:hover i.fa-paint-brush { color: #FFC600; }
.sidebar-social a:hover i.fa-phone { color:#FFC600 }
<div class="row">
<div class="col-md-12">
<div class="sidebar-social">
<ul>
<li>
<a id="header1" rel="nofollow" target="_blank" title="Facebook"><img src="//www.fillmurray.com/200/300">
<span id="header1span">Reklambyrå</span>
</a>
</li>
<li>
<a id="header1" rel="nofollow" target="_blank" title="Facebook"><img src="//www.fillmurray.com/200/300">
<span id="header1span">Reklambyrå</span>
</a>
</li>
</ul>
</div>
</div>
</div>
I was just continuing with making this website and all of a sudden some of my navbar padding goes 'missing' and I can't seem to pinpoint the mistake. I've already played the detective game and commented out some of the stuff I thought was interfering. Luckily I have an original picture before the screw-up and one after. Some of the 'paragraph text' will be 'placeheld' for personal reasons and I think it's irrelevant, unless it's needed in order to fix the problem.
-Thanks.
Before and after picture: http://imgur.com/a/ts1FS
Code:
CSS:
body {
background-color: #1a1a1a;
color: #ccad00;
line-height: 1.9;
font-size: 19px;
}
p.desc{
text-indent: 50px;
}
h1 {
font-family: courier;
color: #ccad00;
}
h2 {
font-family: courier;
color: #ccad00;
text-align: center;
}
#divtitle {
width: 50%;
margin:auto;
padding-top: 50px;
text-align: center;
}
h2
{
font-family:courier;
color: #99cc00;
}
p {
line-height: 1.9
text-size: 19px;
}
#nav {
list-style: none;
font-weight: bold;
margin-bottom: 10px;
width: 100%;
text-align: center;
background-color: #ccad00;
height:40px;
}
#nav ul {
list-style-type: none;
margin: 0px;
padding: 0;
}
#nav li {
margin: 0px;
}
#nav li a {
padding: 10px;
text-decoration: none;
font-weight: bold;
color: #f2f2f2;
background-color: #ccad00;
float: left
}
#nav li a:hover {
color: #0d0d0d;
background-color: #35af3b;
}
.button {
background-color: #ffa600;
border: none;
color: #998200;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 40px;
font-family: courier;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button:hover {
background-color: white;
color: #998200;
}
div#containerbttn {
width: 800px;
height: 100px;
margin: auto;
background-color: green;
}
ul.square{
list-style-type: square;
}
.center {
text-align: center;
}
html:
<div id="nav">
<ul>
<li>Home
</li>
<li>Center
</li>
<li>Rules
</li>
<li>References
</li>
<li>Rankings
</ul>
</div>
<div>
<div id="divtitle" >
<h1> text </h1>
</div> -->
<div id="containerbttn">
<button class="button">GET STARTED!</button>
<button class="button">FAQ</button>
<button class="button">RANKINGS</button>
</div>
<h2> Synopsis: </h2>
<div class="center">
<p class="desc"> Welcome to ***!. This is a free...
<ul class="square">
<li> some text </li>
<li> some text </li>
</ul>
<p class="desc" > text </p>
</div>
</html>
Your problem exists because you have set the height of the #nav element to 40 px. When you add the padding to your a element, you make it larger than the ul element. This can be solved easily by updating two lines of code.
First, remove from css:
#nav{ height:40px; }
Then, add to html after ul but before closing the nav div:
<div style="clear:both;"></div>
Here is a jsfiddle of your working page: https://jsfiddle.net/8o279n5r/
And here is a great answer on what the clear property does: What does the CSS rule clear: both do?
I am having a hard time understanding why there is a small white space next to my webpage. I have checked inspect element and it says the body stops before the white space begins (as in the border of my body is where is want it to be). I am a beginner at writing HTML and CSS so hopefully this will be an easy problem to fix!
HTML:
<!DOCTYPE html>
<html>
<body>
<!--Logo + Social media and login + navbar + search bar-->
<div class="login">
<div class="container-fluid">
<ul class="pull-right">
<li class="loginbutton">Log In</li>
<li>Sign Up</li>
<li></li>
</ul>
<ul class="pull-left">
<li><img class="twitter" src="#"></li>
<li><img class="facebook" src="#"></li>
<li class="pressreleases">Press</li>
</ul>
</div>
</div>
<div class="logo">
<div class="container-fluid">
<img class="logo" src="#" border="0">
</div>
</div>
<div class="nav">
<ul class="navbar">
<li>New</li>
<li>Popular</li>
<li>Database</li>
<li>News</li>
</ul>
</div>
<div class="searchbar">
<div class="container-fluid">
<div class="col-md-12">
<form>
<input class="search" type="text" placeholder="Lookup symbol..." required>
<input name="Submit" class="button" type="submit" value="Search">
</form>
</div>
</div>
</div>
<!-- end Logo + Social media and login + navbar + search bar-->
<div class="frontpage">
<div class="container-fluid">
<div class="row">
<div class="col-md-9">
<div class="headliner">
<h3>New releases</h3>
<p>Learn everything you need to know. <p>
<p>Learn more</p>
</div>
</div>
<div class="col-md-3">
<div class="ad1">
<h1>Ad</h1>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="row">
<ul class="top">
<li>About Us</li>
<li>Contact Us</li>
<li>Sitemap</li>
</ul>
</div>
<div class="row">
<ul class="middle1">
<li>Advertise</li>
<li>Investor Relations</li>
</ul>
</div>
<div class="row">
<ul class="middle2">
<li>Application for Internship/Position</li>
</ul>
</div>
<div class="row">
<ul class="bottom">
<li>Privacy Policy</li>
<li>Terms of use</li>
<li>Feedback</li>
</ul>
</div>
<div class="copyright">
<p>2014<p>
</div>
</footer>
</body>
</html>
CSS:
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Logo + navbar
+ login/social media + search bar v
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
.logo {
max-width: 280px;
margin-right: auto;
margin-left: auto;
}
.logo img {
width: 150%;
}
.logo .container-fluid {
height:135px;
background-color: #ffffff;
width: 100%;
padding-top:5px;
}
.nav .navbar {
background-color: #40517f;
list-style-type: none;
margin: 5;
padding: 5;
overflow: hidden;
position:relative; bottom:50px;
}
.nav .navbar li {
float: left;
border-style: solid;
border-width: 1px;
border-color: #40517f;
}
.nav .navbar li a{
display: block;
width: 300px;
font-weight: none;
color: #40517f;
background-color: #B4C8E8;
text-align: center;
padding: 14px;
text-decoration: none;
font-family: 'Cabin', sans-serif;
}
.nav .navbar li a:hover {
color: #666666;
background-color: #CAD8EF;
FONT-WEIGHT:none;
font-family: 'Cabin', sans-serif;
}
.login .container-fluid {
background-color: #ffffff;
padding-top:5px;
z-index: 1;
height: 30px;
}
.login .pull-right li {
float: right;
list-style: none;
overflow: hidden;
}
.login .pull-right li a {
display: inline;
padding: 10px;
color: #40517f;
font-size: 14px;
font-family: 'Cabin', sans-serif;
}
.login .pull-right li a:hover {
color: #B4C8E8;
margin-top: 0px;
margin-bottom: 0px;
font-family: 'Cabin', sans-serif;
}
.login .pull-left li {
float: left;
list-style: none;
color: #666666;
font-size: 14px;
position: relative;
right: 50px;
overflow: hidden;
}
.login .pull-left li a {
display: inline;
padding: 10px;
opacity: .8;
font-family: 'Cabin', sans-serif;
}
.login .pull-left .facebook {
width: auto;
height: 20px;
vertical-align: sub;
}
.login .pull-left .twitter {
width: 20px;
height: auto;
vertical-align: sub;
}
.login .pull-left .pressreleases {
right: 3 px;
vertical-align: sub;
font-family: 'Cabin', sans-serif;
}
.searchbar {
background-color:#D1D1D1;
text-align:center;
position:relative;bottom:75px;
border-style: solid;
border-width: 2px;
border-color: #40517f;
}
.search {
width: 250px;
padding:8px 15px;
background-color:#FFFFFF;
border:3px solid #D1D1D1;
color: #666666;
font-family: 'Cabin', sans-serif;
}
.button {
position:relative;
padding:6px 15px;
left:-2px;
background-color:#40517f;
color:#ffffff;
opacity: .6;
font-family: 'Cabin', sans-serif;
}
.button:hover {
background-color:#B4C8E8;
border-color: #B4C8E8;
color:#ffffff;
opacity: 1;
font-family: 'Cabin', sans-serif;
}
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Logo + navbar + ^
login/social media + search bar
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Frontpage v
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
.frontpage {
position:relative; bottom:50px;
}
/*
Height and width for all of "frontpage" are just placeholders!
Make sure to get right of them when content is added.
*/
.frontpage .container-fluid .headliner {
background-color: #efefef;
height: 400px;
}
.frontpage .container-fluid .ad1 {
background-color: #efefef;
height: 400px;
}
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Frontpage ^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Footer v
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
footer {
background-color: #666666;
text-align:center;
}
footer .top {
list-style: none;
color: #478bca;
font-family: 'Cabin', sans-serif;
font-size: 18px;
padding-top:15px;
}
footer .top li {
display: inline;
}
footer .top li:before {
content: " | ";
}
footer .top li:first-child:before {
content: none;
}
footer .middle1 {
list-style: none;
color: #478bca;
font-family: 'Cabin', sans-serif;
font-size: 18px;
}
footer .middle1 li {
display: inline;
}
footer .middle1 li:before {
content: " | ";
}
footer .middle1 li:first-child:before {
content: none;
}
footer .middle2 {
list-style: none;
color: #478bca;
font-family: 'Cabin', sans-serif;
font-size: 18px;
}
footer .middle2 li {
display: inline;
}
footer .middle2 li:before {
content: " | ";
}
footer .middle2 li:first-child:before {
content: none;
}
footer .bottom {
list-style: none;
color: #478bca;
font-family: 'Cabin', sans-serif;
font-size: 18px;
}
footer .bottom li {
display: inline;
}
footer .bottom li:before {
content: " | ";
}
footer .bottom li:first-child:before {
content: none;
}
footer .copyright {
background-color: #666666;
height: 60px;
}
footer .copyright p {
color: #D1D1D1;
padding-top: 10px;
font-size: 12px;
}
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Footer ^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
You can try adding
body {
margin:0;
}
Add this code at top of css:
html, body {
margin: 0;
padding: 0;
}
see the result:
http://jsfiddle.net/zpq3uxuq/
Enjoy your code!
The div class="row"s in the footer need to have a div class="container" around them.
If you are referring to the white space between the div.frontpage and footer, then check my answer below:
.frontpage {
position: relative;
bottom: 50px;
}
Remove the bottom:50px to resolve the issue.
bottom explanation
UPDATE
In light of the comment from the OP, I've updated my answer:
The issue is related to the negative margin set by the following CSS declaration:
.row {
margin-right: -15px;
margin-left: -15px;
}
Remove the negative margin to resolve the issue.