I'm working on a project that provided me some pictures of the website look :
As you can see, the logo and the text under are both aligned in the center but the little icon is a bit on the left of the location, how can I do to make it look that way? And also, I want this little icon to not move between my desktop, tablet and smartphone look.
I have tried to use position: absolute, but it's always moving around between desktop and smartphone, it doesn't stay right next to my text. Basically I want this icon to be at the same distance on PC, tablet and phone.
Thanks in advance for all the help you can provide me!
#import url('https://fonts.googleapis.com/css2?family=Shrikhand&display=swap');
/* Header */
header {
box-sizing: border-box;
height: 4rem;
padding-bottom: 1rem;
background-color: white;
}
header h1 {
font-family: 'Shrikhand', sans-serif;
text-align: center;
margin-top: 0rem;
padding-top: 0.5rem;
}
/* Localisation */
.localisation {
display: flex;
justify-content: center;
align-items: center;
background-color: #eaeaea;
height: 2.5rem;
align-items: center;
box-shadow: inset 0px 11px 3px -8px #CCC;
}
.localisation p {
font-size: 15px;
font-weight: 600;
color: #4D4D4D;
}
.localisation i {
position: absolute;
left: 20rem;
}
<script src="https://kit.fontawesome.com/ec6ba8c4d3.js" crossorigin="anonymous"></script>
<!-- Header -->
<header>
<h1>ohmyfood</h1>
</header>
<!-- Localisation -->
<main>
<div class="localisation">
<i class="fa fa-map-marker"></i>
<p>Paris, Belleville</p>
</div>
remove the styling on the icon, let flex handle the position of the elements. If you want to create extra space between the icon and text, use css gap (see example).
Also I added flex-wrap: nowrap; so the text wouldn't wrap under the icon when it gets too small
#import url('https://fonts.googleapis.com/css2?family=Shrikhand&display=swap');
/* Header */
header {
box-sizing: border-box;
height: 4rem;
padding-bottom: 1rem;
background-color: white;
}
header h1 {
font-family: 'Shrikhand', sans-serif;
text-align: center;
margin-top: 0rem;
padding-top: 0.5rem;
}
/* Localisation */
.localisation {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
gap: 5px;
background-color: #eaeaea;
height: 2.5rem;
align-items: center;
box-shadow: inset 0px 11px 3px -8px #CCC;
}
.localisation p {
font-size: 15px;
font-weight: 600;
color: #4D4D4D;
}
.localisation i {
}
<script src="https://kit.fontawesome.com/ec6ba8c4d3.js" crossorigin="anonymous"></script>
<!-- Header -->
<header>
<h1>ohmyfood</h1>
</header>
<!-- Localisation -->
<main>
<div class="localisation">
<i class="fa fa-map-marker"></i>
<p>Paris, Belleville</p>
</div>
header{text-align: center;}
/* Localisation */
.localisation {
display: flex;
justify-content: center;
align-items: center;
background-color: #eaeaea;
height: 2.5rem;
align-items: center;
box-shadow: inset 0px 11px 3px -8px #CCC;
}
.localisation p {
font-size: 15px;
font-weight: 600;
color: #4D4D4D;
padding-left: 10px;
}
<script src="https://kit.fontawesome.com/ec6ba8c4d3.js"
crossorigin="anonymous"></script>
<!-- Header -->
<header>
<h1>ohmyfood</h1>
</header>
<!-- Localisation -->
<main>
<div class="localisation">
<i class="fa fa-map-marker"></i>
<p>Paris, Belleville</p>
</div>
</main>
Just remove position: absolute; from your .localisation i style.
Just remove the .localization i style because you have given the left alignment.
#import url('https://fonts.googleapis.com/css2?family=Shrikhand&display=swap');
/* Header */
header {
box-sizing: border-box;
height: 4rem;
padding-bottom: 1rem;
background-color: white;
}
header h1 {
font-family: 'Shrikhand', sans-serif;
text-align: center;
margin-top: 0rem;
padding-top: 0.5rem;
}
/* Localisation */
.localisation {
display: flex;
justify-content: center;
align-items: center;
background-color: #eaeaea;
height: 2.5rem;
align-items: center;
box-shadow: inset 0px 11px 3px -8px #CCC;
}
.localisation p {
font-size: 15px;
font-weight: 600;
color: #4D4D4D;
}
<script src="https://kit.fontawesome.com/ec6ba8c4d3.js" crossorigin="anonymous"></script>
<!-- Header -->
<header>
<h1>ohmyfood</h1>
</header>
<!-- Localisation -->
<main>
<div class="localisation">
<i class="fa fa-map-marker"></i>
<p> Paris, Belleville</p>
</div>
Related
I found something odd on my website :/ I have a footer that looks quite nice. On bigger screens the items are perfectly centered. However, when I go to a mobile view, it is slightly off (a bit to the right, and if you look at it, you can clearly tell it is not centered).
The html of the page is this:
import * as React from "react"
import * as styles from "./footer.module.css"
import { Link } from "gatsby"
const currentYear = new Date().getFullYear()
const Footer = () => {
return (
<footer className={styles.flexFooter}>
<section className={styles.footerTopSection}>
<ul className={styles.footerTopList}>
<li>
<h4>
<Link to="/home" className={styles.footerLogo}>
Humital
</Link>
</h4>
</li>
</ul>
<ul className={styles.footerTopList}>
<li>
<h4>Over Humital</h4>
</li>
<li>
<Link to="/about">leer ons kennen</Link>
</li>
</ul>
<ul className={styles.footerTopList}>
<li>
<h4>Help me</h4>
</li>
<li>
<Link to="/contact">Contacteer ons</Link>
</li>
<li>
<Link to="https://calendly.com/somelink" target="_blank">
get appointment
</Link>
</li>
</ul>
</section>
<section className={styles.footerBottomSection}>
<div className={styles.footerBottomWrapper}>
<p>©Copyright {currentYear} Humital - Made with ❤️</p>
<span>- All Rights Reserved -</span>
</div>
<div className={styles.footerBottomWrapper}>
<Link to="/sitemap">Sitemap</Link>|
<Link to="/privacy">Privacy Policy</Link>
</div>
</section>
</footer>
)
}
export default Footer
The CSS for this is pretty simple:
.flexFooter {
display: flex;
flex-flow: row wrap;
margin: 0 auto;
width: 100%;
}
footer {
background-color: #2b2b2b;
opacity: 0.95;
width: 100%;
margin-top: auto;
bottom: 0;
color: whitesmoke;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: whitesmoke;
text-transform: lowercase;
letter-spacing: 0.2px;
}
h4 {
font-size: clamp(1rem, 1.5vw, 2rem);
margin-top: 1rem;
margin-bottom: 0.5rem;
text-transform: uppercase;
align-self: center;
}
/*Top Footer*/
.footerTopSection {
width: 100%;
text-align: center;
padding-top: 1rem;
}
.footerTopList {
width: 100%;
}
.footerTopList li {
width: 100%;
}
.footerLogo {
color: #78c0a8;
font-size: clamp(2rem, 3.3vw, 4rem);
text-transform: none;
letter-spacing: normal;
}
/*Bottom footer*/
.footerBottomSection {
width: 100%;
padding: 1rem;
border-top: 1px solid whitesmoke;
margin-top: 1rem;
text-align: center;
}
.footerBottomSection > div:first-child {
margin: 0 auto;
text-align: center;
}
.footerBottomWrapper {
text-align: center;
width: 100%;
margin-top: 1rem;
}
.footerBottomWrapper a {
padding: 0.5rem;
font-weight: bold;
font-size: 0.8rem;
text-align: center;
}
.footerBottomWrapper > p,
.footerBottomWrapper > span {
font-weight: lighter;
}
It's just ab it off on smaller sizes, and I can't see why :( Any help is appreciated! :)
Use the below syntax to center align your footer:
.flexFooter{
display:flex;
align-items:center;
justify-content:center
}
It should work fine on all devices. You may have to add media queries to adjust some pieces of stuff depending on the font sizes and all. Don't forget to add the responsive meta tag. I hope it helps!
Good morning. I'm new to html/css and to programming in general and this is my first post. Below is my current code. I'd like to do three things, that I'm currently unable to do:
to center the purple menu with the four boxes: I've tried to move the nav bar inside the header, but without success.
to put in a single line the card with red wine and white wine and below them, the other two. I've created two DIV parent directories, each with two childs.
to put the "comprar" (to buy) button below each picture.
Thank you very much in advance.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vinería Baco</title>
<!--link css-->
<link rel="stylesheet" href="./estilos.css">
</head>
<body>
<!--seccion hero/banner-->
<header>
<p><h1 class="h1_rojo">Vinería Baco</h1></p>
<p><h2 class="h2_turquesa">El mejor vino de todo Berisso</h2></p>
<!--Menu de navegacion-->
<nav>
<ul>
<li class="menu menu__item">Contactanos</li>
<li class="menu menu__item">Facebook</li>
<li class="menu menu__item">Instagram</li>
<li class="menu menu__item">Acerca de nosotros</li>
</ul>
</nav>
</header>
<!--Seccion main-->
<main>
<!--cards 1 to 2-->
<div class="card1">
<img alt="vino tinto" src="../img/tintos/tintos.jpg"width=150" height="70"><button type="button">Comprar</button><br>
<img alt="vino blanco" src="../img/blancos/blancos.jpg"width=150" height="70"><button type="button">Comprar</button><br>
<!--cards 3 to 4-->
<div class="card2">
<img alt="vino rosado" src="../img/rosados/rosados.jpg"width=150" height="70"><button type="button">Comprar</button><br>
<img alt="vinos especiales" src="../img/especiales/especiales.jpg"width=150" height="70"><button type="button">Comprar</button><br></div>
</main><br><br>
<!--Seccion footer-->
<footer>
<h4>2021 | Hecho por MGP | 2021</h4>
</footer>
</body>
</html>
CSS:
/*HERO SECTION*/
/*Encabezados*/
.h1_turquesa {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:#00868b;
text-align: center;
}
.h1_rojo {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:#8b0000;
text-align: center;
}
.h1_azul {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:rgb(138, 43, 226);
text-align: center;
}
.h1_verde {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color: rgb(0, 128, 0);
text-align: center;
}
h2 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:rgb(139, 0, 139);
text-align: center;
}
/*Párrafos*/
.parr {
display: block;
font-size: 18px;
color: black;
text-align: justify;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
/*Fondo*/
body {
background-color: rgb(197, 189, 170);
}
/*Imágenes*/
img {
display: block;
max-width:500px;
max-height:500px;
width: auto;
height: auto;
}
/*MENU*/
.menu {
background-color: rgb(175, 76, 122);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family: monospace;
font-size: 16px;
}
.menu__item a {
text-decoration: none;
color: white;
}
/*MAIN*/
/*Card section*/
.card1{
display: flex;
background-color: rgb(197, 189, 170);
width: 90%;
margin: 10px;
margin: 10px;
width: 60%;
justify-content: space-between;
align-items: center;
}
.card2{
display: flex;
background-color: rgb(197, 189, 170);
width: 90%;
margin: 10px;
margin: 10px;
width: 60%;
justify-content: space-between;
align-items: center;
}
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
/*FOOTER*/
footer{
display: flex;
justify-content: center;
align-items: center;
padding: 50px 0px;
}
Welcome to Stack Overflow. I would suggest running your code through a beautifier to clean up everything and you can see if you accidentally forgot to close a tag. In your instance, you forgot to close one of your div tags which I closed for you. I also nested both of your divs card1 and card2 into a card-container. I went ahead and flexed that div with and justified it to the center. I also added a .flex class to align your unordered list into the center. Please see those changes below. I am unsure what you mean about part 2 of your question, if you can please elaborate further.
/*HERO SECTION*/
/*Encabezados*/
.h1_turquesa {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:#00868b;
text-align: center;
}
.h1_rojo {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:#8b0000;
text-align: center;
}
.h1_azul {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:rgb(138, 43, 226);
text-align: center;
}
.h1_verde {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color: rgb(0, 128, 0);
text-align: center;
}
h2 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
color:rgb(139, 0, 139);
text-align: center;
}
/*Párrafos*/
.parr {
display: block;
font-size: 18px;
color: black;
text-align: justify;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
/*Fondo*/
body {
background-color: rgb(197, 189, 170);
}
/*Imágenes*/
img {
display: block;
max-width:500px;
max-height:500px;
width: auto;
height: auto;
}
/*MENU*/
.menu {
background-color: rgb(175, 76, 122);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family: monospace;
font-size: 16px;
}
.menu__item a {
text-decoration: none;
color: white;
}
/*MAIN*/
/*Card section*/
.card1{
display: flex;
flex-direction: column;
background-color: rgb(197, 189, 170);
width: 90%;
margin: 10px;
margin: 10px;
width: 60%;
justify-content: space-between;
align-items: center;
}
.card2{
display: flex;
flex-direction: column;
background-color: rgb(197, 189, 170);
width: 90%;
margin: 10px;
margin: 10px;
width: 60%;
justify-content: space-between;
align-items: center;
}
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
/*FOOTER*/
footer{
display: flex;
justify-content: center;
align-items: center;
padding: 50px 0px;
}
.flex {
display: flex;
justify-content: center;
}
.card-container {
display: flex;
justify-content: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vinería Baco</title>
<!--link css-->
<link rel="stylesheet" href="./estilos.css">
</head>
<body>
<!--seccion hero/banner-->
<header>
<p><h1 class="h1_rojo">Vinería Baco</h1></p>
<p><h2 class="h2_turquesa">El mejor vino de todo Berisso</h2></p>
<!--Menu de navegacion-->
<nav>
<ul class="flex">
<li class="menu menu__item">Contactanos</li>
<li class="menu menu__item">Facebook</li>
<li class="menu menu__item">Instagram</li>
<li class="menu menu__item">Acerca de nosotros</li>
</ul>
</nav>
</header>
<!--Seccion main-->
<main>
<!--cards 1 to 2-->
<div class="card-container">
<div class="card1">
<img alt="vino tinto" src="https://dummyimage.com/600x350/000/fff"width=150" height="70"><br><button type="button">Comprar</button><br>
<img alt="vino blanco" src="https://dummyimage.com/600x350/000/fff" width=150" height="70"><br><button type="button">Comprar</button><br>
</div>
<!--cards 3 to 4-->
<div class="card2">
<img alt="vino rosado" src="https://dummyimage.com/600x350/000/fff"width=150" height="70"><br><button type="button">Comprar</button><br>
<img alt="vinos especiales" src="https://dummyimage.com/600x350/000/fff"width=150" height="70"><br><button type="button">Comprar</button><br>
</div>
</main><br><br>
</div>
<!--Seccion footer-->
<footer>
<h4>2021 | Hecho por MGP | 2021</h4>
</footer>
</body>
</html>
EDIT: inserted dummy images into HTML. It appears buttons are displaying below the images as expected.
There's a mindset that always help me out.
If you have problems positioning something, create a div parent.
I create as many div parents as needed.
For example:
<div>
<div>My element 1</div>
<div>My element 2</div>
<div>My element 3</div>
<div>My element 4</div>
</div>
Sometimes I might want that the first two elements get positioned differently, so I create another parent that will wrap the elements I want to position in a different way.
<div>
<div>
<div>My element 1</div>
<div>My element 2</div>
</div>
<div>
<div>My element 3</div>
<div>My element 4</div>
</div>
</div>
If you do that, it will solve many problems
When I run my code in the browser, I have this little line of white space at the bottom of the page. I’ve been trying different solutions but can’t seem to find one that works. Below is the home.html page. Maybe someone here can shed some light into the problem.
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="cooper, scooper, dog, pop, pick, up>
<meta name="author" content="primarysnail">
<meta name="viewport" content="width=device-width">
<meta name="description" content="connecting clients in need of dog pick pick up srvice with scoopers who will come to the client and scoop the poop">
<title>CoopersScoopers || Home</title>
<link rel="stylesheet" type="text/css" href="../CSS/style.css">
</head>
<body>
<header> <!-- company name top left; nav bar top right -->
<div class="container">
<div class="branding">
<h1><span>cooper</span>Scoopers</h1>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Contact Us</li>
<li>Find a Scooper</li>
</ul>
</nav>
</div>
</header>
<section class="showcase"> <!-- showcase section; button to find scooper (./find.html) -->
<div class="container">
<h1>Leave the</h1>
<br>
<h1>Poo to the</h1>
<br>
<h1>Professionals.</h1>
<button type="button">Connect With a Scooper Today</button>
</div>
</section>
<section class="info-bar"> <!-- info bar; shows scooper process in 3 sections -->
<div class="container">
<div class="box">
<img src="../images/poop.jpg">
<h3>Connect With a Local Scooper</h3>
</div>
<div class="box">
<img src="../images/location.jpg">
<h3>Mark Your Poo</h3>
</div>
<div class="box">
<img src="../images/calendar.jpg">
<h3>Schedule Future Scoops</h3>
</div>
</div>
</section>
<section class="testimonials">
<div class="container">
<h1>Come Experience the Joy of a Poop-Free Life.</h1>
</section>
</body>
<footer>
<p>Copyright © primarySnail//</p>
</footer>
</html>
Here is the linked style.css file:
body {
font-family: Tahoma, Verdana, Segoe;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #ffffff;
}
/* global */
.container {
margin: auto;
width: 80%;
overflow: hidden;
}
ul {
margin: 0;
padding: 0;
}
button {
height: 50px;
background-color: #ffff00;
opacity: 0.8;
border: none;
padding-right: 30px;
padding-left: 30px;
float: left;
margin-top: -20px;
float: right;
}
button a {
text-decoration: none;
color: #4b0082;
font-weight: bold;
font-size: 25px;
}
/* header */
header {
padding-top: 30px;
min-height: 70px;
border-bottom: 4px solid #f0e68c;
background-color: #ffffff;
color: #8a2be2;
font-size: 10px;
}
header a {
text-decoration: none;
}
nav a {
color: #8a2be2;
text-decoration: none;
text-transform: uppercase;
font-size: 10px;
}
header span {
font-size: 15px;
}
header li {
float: left;
display: inline;
padding: 0px 10px 0px 10px;
}
.branding {
float: left;
}
.branding h1 {
margin: 0;
padding: 0px 10px 0px 10px;
border: 4px solid #8a2be2;
}
header nav {
float: right;
margin-top: 10px;
}
header .current {
border: 1px solid #999;
background-color: #8a2be2;
border-collapse: collapse;
}
header .current a {
color: #ffffff;
font-weight: bold;
}
/* showcase */
.showcase {
background-color: #8a2be2;
color: #ffffff;
text-align: left;
min-height: 200px;
border-bottom: 4px solid #f0e68c;
}
.showcase h1 {
font-size: 55px;
margin-top: 0;
margin-bottom: 0;
padding: 0px;
display: inline-block;
}
/* info bar*/
.info-bar {
margin-top: 20px;
border-bottom: 4px solid #f0e68c;
}
.info-bar .box {
float: left;
width: 30%;
padding: 10px;
text-align: center;
}
.info-bar .box img {
width: 90px;
height: 90px;
}
/* testimonials */
.testimonials {
background-color: #8a2be2;
color: #ffffff;
}
.testimonials h1 {
text-align: center;
}
/* footer */
footer {
background-color: #f0e68c;
margin-top: 0px;
padding: 5px;
text-align: center;
color: black;
opacity: 0.6;
}
I cannot for the life of me figure out why that little line of white space is in there at the very bottom. screenshot
Yes, I have observed white space showing in the bottom. It is because the elements inside body tag is not occupying the full available body size.
elemets heights are as
body- 722
header- 104
.showcase- 251enter code here
.info-bar- 201
.testimonials- ~71
footer- ~62
the white space in the botom is remaining area of viewport. If you make the browser smaller the white space will go away.
To fix this proble you can use below css to the body.
body {
font-family: Tahoma, Verdana, Segoe;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #ffffff;
/* Add below lines*/
display: flex;
flex-direction: column;
align-items: stretch;
}
So I made a post similar to this one, since I didn't get a precise answer and didn't understand the instructions. So I am once again asking for your support.
There are a couple of issues regarding my nav bar that I am unable to fix. One of them is a button sticking inside of the nav bar, but it doesn't even belong in the div class.
Navigation Bar
The second issue is that I can't line the logo/text [SINUS] and the links together in one line.
Any help would be appreciated!
/*====================
The CSS File
Section 1:
Buttons
=====================*/
button {
background-color: #358cf0;
border: none;
border-radius: 18px;
text-align: center;
text-decoration: none;
opacity: 0.8;
font-size: 14px;
color: rgb(255, 255, 255);
padding: 12px 48px;
transition: 0.3s;
outline: none;
}
button:hover {
opacity: 1;
}
ul li {
display: inline-block;
padding: 10px;
font-size: 20px;
font-family: raleway;
}
ul li:hover {
color: orange;
}
/*====================
The CSS File
Section 2:
Alerts
=====================*/
.container {
position: fixed;
top: 74%;
right: 0;
left: 77%;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-family: basic;
}
.modal {
width: 40%;
min-width: 20rem;
background-color: #ffffff;
border-radius: 12px;
}
.modal-header {
display: flex;
align-items: center;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
background-color: #358cf0;
padding: 8px 10px;
color: #fff;
font-size: 110%;
font-weight: 600;
font-family: basic;
}
.modal-content {
padding: 1rem;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.modal-footer {
text-align: center;
}
/*====================
The CSS File
Section 3:
Body etc.
=====================*/
body {
background-color: #252036;
}
#navigation-container {
width: 1200px;
margin: 0 auto;
height: 70%;
}
.navigation-bar {
background-color: #1c172c;
position: fixed;
width: 100%;
left: 0;
top: 0;
text-align: right;
}
.navigation-bar ul {
padding: 0px;
margin: 0px;
text-align: right;
display: inline-block;
vertical-align: top;
}
.navigation-bar li {
list-style-type: none;
padding: 0px;
display: inline;
text-align: right;
}
.navigation-bar li a {
color: black;
font-size: 16px;
font-family: basic;
text-decoration: none;
line-height: 70px;
padding: 5px 15px;
opacity: 0.7;
}
#menu {
float: right;
}
/*====================
The CSS File
Section 4:
Text
=====================*/
#font-face {
font-family: basic;
src: url(Helmet-Regular.ttf);
}
h1 {
font-family: basic;
color: white;
font-size: 390%;
text-align: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sccp.css">
<title>Sinus - 【Home】</title>
<link rel="icon" href="titl.ico">
<link rel="apple-touch-icon" href="titl.ico" />
</head>
<body>
<div class="navigation-bar">
<div id="navigation-container">
<h1>SINUS</h1>
<ul>
<li>Home</li>
</ul>
</div>
</div>
<button>Download</button>
<div class="container" role="alert">
<div class="modal">
<div class="modal-header">
UPDATE! Sinus 1.0v
</div>
<div class="modal-content">
Here new stuff go gogogo
<br>Read more...
</div>
<div class="modal-footer">
</div>
</div>
</div>
</body>
</html>
To align the logo and links, use flex on the #navigation-container:
#navigation-container {
display: flex;
justify-content: space-between;
align-items: center;
}
justify-content: space-between will put the maximum space between the contents - in this case your logo and ul that contain the links. align-items:center lines them up vertically.
https://codepen.io/doughballs/pen/RwPrYoX
Not sure what your issue with the button is but because your nav has position:fixed, it is being taken out of the flow of the page, so the button doesn't 'know' it is there. If you wanted it to sit under the nav, you need to add a container with margin-top to push it down. But I'm not sure what your issue is with it, clarify and I'll amend the codepen.
I'm using flexbox to center align a div within a div. I'm adding a third div within the second div that I want underneath the second and to float to the right of the size of the second div. If I set it to float right, it's still being forced into the second div. How can I force it below the second div and float it right like below?
.welcome {
font-size: 2.3em;
line-height: 1.15;
font-weight: bold;
width: 600px;
display: flex;
margin: 0 auto;
align-items: center;
justify-content: center;
}
.welcometxt {
width: 450px;
display: flex;
margin: 0 auto;
align-items: center;
justify-content: center;
text-align: justify;
}
.linksect {
width: 400px;
}
.cursive,
.infolink {
font-family: 'Marck Script', cursive;
}
.infolink,
.infoarrow {
color: #8d0700;
font-weight: bold;
text-decoration: none;
font-size: 2em;
}
.infoarrow {
font-size: 1.5em;
padding-left: 10px;
}
<link href="https://www.w3schools.com/lib/w3.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Marck+Script" rel="stylesheet">
<div class="w3-row w3-margin w3-container w3-white w3-padding-32">
<p class="cursive welcome w3-center">Welcome to the Historic Players Playhouse, home of The Players, founded in 1911.</p>
<hr class="w3-padding-large">
<div class="welcometxt">
<p>The Players is an organization of gentlemen dedicated to the preservation of amateur theater. Our members come from diverse backgrounds and locations but share a common interest in amateur theater. We welcome as members all gentlemen who wish to share
in the camaraderie of The Players.</p>
<div class="linksect">
Read More <span class="fa fa-angle-double-right infoarrow" aria-hidden="true"></span>
</div>
</div>
</div>
You can add flex-direction: column; to your welcometxt, change the width of linksect to 100% and align its content to the right:
.welcome {
font-size: 2.3em;
line-height: 1.15;
font-weight: bold;
width: 600px;
display: flex;
margin: 0 auto;
align-items: center;
justify-content: center;
}
.welcometxt {
width: 450px;
display: flex;
margin: 0 auto;
align-items: center;
justify-content: end;
text-align: justify;
flex-direction: column;
}
.linksect {
width: 100%;
text-align: right;
}
.cursive,
.infolink {
font-family: 'Marck Script', cursive;
}
.infolink,
.infoarrow {
color: #8d0700;
font-weight: bold;
text-decoration: none;
font-size: 2em;
}
.infoarrow {
font-size: 1.5em;
padding-left: 10px;
}
<link href="https://www.w3schools.com/lib/w3.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Marck+Script" rel="stylesheet">
<div class="w3-row w3-margin w3-container w3-white w3-padding-32">
<p class="cursive welcome w3-center">Welcome to the Historic Players Playhouse, home of The Players, founded in 1911.</p>
<hr class="w3-padding-large">
<div class="welcometxt">
<p>The Players is an organization of gentlemen dedicated to the preservation of amateur theater. Our members come from diverse backgrounds and locations but share a common interest in amateur theater. We welcome as members all gentlemen who wish to share
in the camaraderie of The Players.</p>
<div class="linksect">
Read More <span class="fa fa-angle-double-right infoarrow" aria-hidden="true"></span>
</div>
</div>
</div>
You don't need flex to take paragraph at the center, having already margin: 0 auto;
.welcometxt {
width: 450px;
margin: 0 auto;
align-items: center;
justify-content: center;
text-align: justify;
}
than:
.infolink {
float:right;
}
.linksect {
width: 400px;
float:right;
http://jsfiddle.net/9dhw5zLp/
}
And heres the version free of flexbox, as you asked. Html stays the same as you posted :)
.welcome, .welcometxt, .linksect{
display: block;
margin: 0 auto;
}
.welcome {
font-size: 2.3em;
line-height: 1.15;
font-weight: bold;
width: 600px;
}
.welcometxt {
width: 450px;
}
.linksect {
width: 400px;
text-align: right;
}
.cursive,
.infolink {
font-family: 'Marck Script', cursive;
}
.infolink,
.infoarrow {
color: #8d0700;
font-weight: bold;
text-decoration: none;
font-size: 2em;
}
.infoarrow {
font-size: 1.5em;
padding-left: 10px;
}
You can do it like this:
.welcome {
font-size: 2.3em;
line-height: 1.15;
font-weight: bold;
width: 600px;
display: flex;
margin: 0 auto;
align-items: center;
justify-content: center;
}
.welcometxt {
width: 450px;
display: flex; /* displays children inline */
flex-direction: column; /* stacks children vertically */
margin: 0 auto;
align-items: center;
justify-content: center;
text-align: justify;
}
.linksect {
width: 100%; /* modified */
display: flex; /* added */
justify-content: flex-end; /* horizontal alignment, aligns them to the far right */
align-items: center; /* vertical alignment / centering */
}
.cursive,
.infolink {
font-family: 'Marck Script', cursive;
}
.infolink,
.infoarrow {
color: #8d0700;
font-weight: bold;
text-decoration: none;
font-size: 2em;
}
.infoarrow {
font-size: 1.5em;
padding-left: 10px;
}
<link href="https://www.w3schools.com/lib/w3.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Marck+Script" rel="stylesheet">
<div class="w3-row w3-margin w3-container w3-white w3-padding-32">
<p class="cursive welcome w3-center">Welcome to the Historic Players Playhouse, home of The Players, founded in 1911.</p>
<hr class="w3-padding-large">
<div class="welcometxt">
<p>The Players is an organization of gentlemen dedicated to the preservation of amateur theater. Our members come from diverse backgrounds and locations but share a common interest in amateur theater. We welcome as members all gentlemen who wish to share
in the camaraderie of The Players.</p>
<div class="linksect">
Read More <span class="fa fa-angle-double-right infoarrow" aria-hidden="true"></span>
</div>
</div>
</div>