Creating space between two images - html

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>

Related

How to set up a nav bar?

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>

How do I add corner logos into Footer using Html & CSS?

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

How to center the ul in the HTML

I have this html and CSS code on which I have spent the last 3 hrs and I am still not able to figure out how to center align the top menu bar in my code. The code is as follows:
#container ul {
list-style: none;
margin: auto;
padding: 0;
}
#container ul li a {
color: #FFFFFF;
}
#container ul li {
background-color: #6068FF;
width: 180px;
border: 1px solid white;
height: 50px;
line-height: 50px;
text-align: center;
float: left;
align-items: center;
color: #FFFFFF;
font-size: 18;
}
#container ul li:hover {
background-color: #0BF5F5;
}
<div id="container">
<ul>
<li><a style="text-decoration:none;" href="default.asp">Student Attendance</a></li>
<li><a style="text-decoration:none;" href="news.asp">Edit Students</a></li>
<li><a style="text-decoration:none;" href="contact.asp">Profile</a></li>
<li><a style="text-decoration:none;" href="about.asp">Logout</a></li>
</ul>
</div>
Here's your updated CSS:
Added text-align: center on the <ul> tag.
#container ul {
...
text-align: center;
}
Removed float: left, and added display: inline-block on <li> tags.
#container ul li {
display: inline-block;
...
/* float: left; */
}
Use flexbox for this:
#container {
display: flex; /* new */
}
#container ul {
list-style: none;
margin: auto;
padding: 0;
}
#container ul li a {
color: #FFFFFF;
}
#container ul li {
background-color: #6068FF;
width: 180px;
border: 1px solid white;
height: 50px;
line-height: 50px;
text-align: center;
float: left;
align-items: center;
color: #FFFFFF;
font-size: 18;
}
#container ul li:hover {
background-color: #0BF5F5;
}
<div id="container">
<ul>
<li><a style="text-decoration:none;" href="default.asp">Student Attendance</a></li>
<li><a style="text-decoration:none;" href="news.asp">Edit Students</a></li>
<li><a style="text-decoration:none;" href="contact.asp">Profile</a></li>
<li><a style="text-decoration:none;" href="about.asp">Logout</a></li>
</ul>
</div>
You either need to display the list as an inline element or give it a fixed with, otherwise it always will take full available horizontal space.
#container ul {
display: inline-block;
list-style:none;
margin:auto;
padding: 0;
}
/* or */
#container ul {
width: 50%; /* whatever */
list-style:none;
margin:auto;
padding: 0;
}
Here's your code without the float:left;
#container ul {
list-style:none;
margin:auto;
padding: 0;
}
#container ul li a{
color:#FFFFFF;
}
#container ul li{
background-color:#6068FF;
width:180px;
border:1px solid white;
height:50px;
line-height:50px;
text-align:center;
#float:left;
align-items:center;
color:#FFFFFF;
font-size:18;
}
#container ul li:hover{
background-color:#0BF5F5;
}
<div id="container">
<ul>
<li><a style="text-decoration:none;"href="default.asp">Student Attendance</a></li>
<li><a style="text-decoration:none;"href="news.asp">Edit Students</a></li>
<li><a style="text-decoration:none;"href="contact.asp">Profile</a></li>
<li><a style="text-decoration:none;"href="about.asp">Logout</a></li>
</ul>
</div>
Add inline-block to the list and use text-align:center; on the #container
#container {
text-align: center;
}
#container ul {
list-style: none;
margin: auto;
padding: 0;
display: inline-block;
}
#container ul li a {
color: #FFFFFF;
}
#container ul li {
background-color: #6068FF;
width: 180px;
border: 1px solid white;
height: 50px;
line-height: 50px;
text-align: center;
float: left;
align-items: center;
color: #FFFFFF;
font-size: 18;
}
#container ul li:hover {
background-color: #0BF5F5;
}
<div id="container">
<ul>
<li><a style="text-decoration:none;" href="default.asp">Student Attendance</a></li>
<li><a style="text-decoration:none;" href="news.asp">Edit Students</a></li>
<li><a style="text-decoration:none;" href="contact.asp">Profile</a></li>
<li><a style="text-decoration:none;" href="about.asp">Logout</a></li>
</ul>
</div>

Vertically Center Various Text in Header?

This can probably be fixed insanely easy but I'm just having such a hard time at doing it.
So, I want to make both my name and the navigation bar in the header appear at the center vertically. My current code only makes my name be centered, since it is bold and the font-size is bigger.
This is the code:
HTML:
<div id="header">
<ul>
<div id="header-wrapper">
<div class="header-name">
<li>
<a href="/index.html">
<span class="first"><strong>First</strong></span>
<span class="last"><strong> Last</strong></span>
</a>
</li>
</div>
<div class="header-nav">
<li>
Contact</li>
<li>
Portfolio</li>
<li>
About
</li>
<li>
Home
</li>
</div>
</div>
</ul>
CSS:
#header-wrapper {
width: 960px;
margin: 0 auto;
position: relative;
}
#header ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: orange;
box-shadow: 0px 0px 10px 3px rgba(0, 0, 0, 0.2);
}
#header .header-name li {
float: left;
}
#header .header-nav li {
float: right;
vertical-align: middle;
}
#header li a {
font-size: 15px;
display: block;
color: #FFF;
text-align: center;
padding: 20px 16px;
text-decoration: none;
}
#header .header-name li a {
font-size: 22px;
}
#header ul li a .first {
color: #ccc;
}
#header a {
vertical-align: middle;
}
Your HTML is invalid. A ul needs to have an li as direct children. Instead, you have divs as direct children with nested li's
That said, add display: flex; align-items: center; justify-content: space-between; to #header-wrapper to center those elements vertically.
#header-wrapper {
width: 960px;
margin: 0 auto;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
}
#header ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: orange;
box-shadow: 0px 0px 10px 3px rgba(0, 0, 0, 0.2);
}
#header .header-name li {
float: left;
}
#header .header-nav li {
float: right;
vertical-align: middle;
}
#header li a {
font-size: 15px;
display: block;
color: #FFF;
text-align: center;
padding: 20px 16px;
text-decoration: none;
}
#header .header-name li a {
font-size: 22px;
}
#header ul li a .first {
color: #ccc;
}
#header a {
vertical-align: middle;
}
<div id="header">
<ul> <div id="header-wrapper">
<div class="header-name">
<li>
<a href="/index.html">
<span class="first"><strong>First</strong></span>
<span class="last"><strong> Last</strong></span>
</a>
</li>
</div>
<div class="header-nav">
<li>
Contact</li>
<li>
Portfolio</li>
<li>
About
</li>
<li>
Home
</li>
</div>
</div>
</ul>

Navigation and title won't center

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>