I have built a standard footer, emulating the tourlife.com footer. However my link next to the instagram image isn't centered with the image, also the links "terms" and "help" are also out of alignment with the form. This is my second attempt using w3school's 'css grid of boxes/ equal width boxes'.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<footer class="clearfix">
<div class="box">
<img class="ig_logo" src="images/instagramicon.jpg">
#TOURLIFE
</div>
<div class="box">
<a class="biggertext" href="#">TERMS</a>
<a class="biggertext" href="#">HELP</a>
<form class="form">
<input class="enter" type="email" placeholder="email">
<button type="submit" class="button_1">SUBSCRIBE</button>
</form>
</div>
<div class="box">
<p>© Copyright Ben Cotta 2020</p>
</div>
</footer>
</body>
</html>
CSS:
* {
margin: 0;
padding: 0;
text-decoration: none;
}
/* Main Footer */
.box {
float: left;
width: 33.33%;
padding: 20px 0px;
box-sizing: border-box;
text-align: center;
color: black;
font-size: 13px;
border-top: 1px solid black;
}
.clearfix::after {
content: " ";
clear: both;
display: table;
}
.box .biggertext {
font-size: 16px;
padding: 0px 4px;
margin-left: 6px;
}
.box a:visited {
color: black;
}
.ig_logo {
height: 100%;
width: 20px;
}
/* Middle Box */
.form {
float: right;
}
.enter {
width: 10vw;
margin-right: 10px;
padding: 6px 10px;
}
.button_1 {
background-color: black;
color: white;
padding: 6px 10px;
width: 8vw;
font-size: 12px;
text-align: center;
}
/* Right Box */
This is way easier to do with flexbox.
When you set your box width to 33.33% it doesn't know what to refer to. If you set the height of your body it will automatically give 100% width of your screen and the child to your body has a reference.
By typing "display: flexbox" your items under that class will align in a row. Voila!
By using "justify-content", you can decide how you want to spread your items and with "align-items" you can center your items vertically. You must give them space to do this though.
Your Instagram-pic didn't work, so I added a new link. I think it should work.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Main Footer */
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: Arial, Helvetica, sans-serif;
}
.clearfix {
border-top: 1px solid black;
width: 80%;
height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
}
.box {
display: flex;
align-items: center;
}
.box a {
text-decoration: none;
padding-right: 10px;
color: #000;
}
.button_1 {
background-color: black;
color: #fff;
border: none;
outline: none;
padding: 10px;
}
.enter {
padding: 8px 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<footer class="clearfix">
<div class="box">
<img src="https://img.icons8.com/fluent/48/000000/instagram-new.png" />
#TOURLIFE
</div>
<div class="box">
<a class="biggertext" href="#">TERMS</a>
<a class="biggertext" href="#">HELP</a>
<form class="form">
<input class="enter" type="email" placeholder="email" />
<button type="submit" class="button_1">SUBSCRIBE</button>
</form>
</div>
<div class="box">
<p>© Copyright Ben Cotta 2020</p>
</div>
</footer>
</body>
</html>
https://jsfiddle.net/battleaxe/5rc9asn0/
Related
I want the style of this page of mine to be justified in the center but it doesn't work.
Especially for the converter tab I want each element to have its own line and must be centered inside the div container.
* {
box-sizing: border-box;
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
padding: 2rem 1rem;
margin: 0 auto;
}
.converter-tab {
display: block;
align-items: center;
color: white;
background: #6943ff;
width: 550px;
height: 285px;
}
.converter-input {
width: 117px;
height: 83px;
background: none;
border: solid 1px white;
color: white;
font-size: 2.5rem;
}
.converter-btn {
width: 117px;
height: 42px;
border-radius: 5px;
border: none;
}
.output {
background: #f4f4f4;
color: #5a537b;
width: 550px;
height: 400px;
}
.length,
.volume,
.mass {
width: 500px;
height: 108px;
background: #ffffff;
margin-bottom: 20px;
margin-top: 10px;
}
<!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" />
<link rel="stylesheet" href="style.css" />
<title>Unit Conversion</title>
</head>
<body>
<div class="container">
<div class="converter-tab">
<h2>Metric/Imperial Unit Conversion</h2>
<input type="text" id="input-el" class="converter-input" />
<button class="converter-btn" id="convert-btn">Convert</button>
</div>
<div class="output">
<div class="length" id="length-el">
<h2>Length (Meter/Feeet)</h2>
<p class="" id="output-el"></p>
</div>
<div class="volume" id="volume-el">
<h2>Volume (Liters/Gallons)</h2>
<p class="" id="output-el2"></p>
</div>
<div class="mass" id="mass-el">
<h2>Mass (Kilograms/Pounds)</h2>
<p class="" id="output-el3"></p>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
I tried the display block and in-line block but the element inside the container is not moving.
i think the container class is the implemented one because he is the in the general div that contain the "converter-tab" div , and the reason of not-centered elements is the padding and margin css classes.
try to remove it or replace it by this one :
.container {
margin: auto;
}
What you really have to do in this case is to assign a property text-align: center
to your .converter-tab class and moreover you have to wrap your h2, input and button individually inside a separate div for each one.
You can check my working snippet below:
* {
box-sizing: border-box;
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
padding: 2rem 1rem;
margin: 0 auto;
}
.converter-tab {
display: block;
align-items: center;
color: white;
background: #6943ff;
width: 550px;
height: 285px;
text-align: center;
}
.converter-input {
width: 117px;
height: 83px;
background: none;
border: solid 1px white;
color: white;
font-size: 2.5rem;
}
.converter-btn {
width: 117px;
height: 42px;
border-radius: 5px;
border: none;
}
.output {
background: #f4f4f4;
color: #5a537b;
width: 550px;
height: 400px;
}
.length,
.volume,
.mass {
width: 500px;
height: 108px;
background: #ffffff;
margin-bottom: 20px;
margin-top: 10px;
}
<!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" />
<link rel="stylesheet" href="style.css" />
<title>Unit Conversion</title>
</head>
<body>
<div class="container">
<div class="converter-tab">
<div><h2>Metric/Imperial Unit Conversion</h2></div>
<div><input type="text" id="input-el" class="converter-input" /></div>
<div><button class="converter-btn" id="convert-btn">Convert</button></div>
</div>
<div class="output">
<div class="length" id="length-el">
<h2>Length (Meter/Feeet)</h2>
<p class="" id="output-el"></p>
</div>
<div class="volume" id="volume-el">
<h2>Volume (Liters/Gallons)</h2>
<p class="" id="output-el2"></p>
</div>
<div class="mass" id="mass-el">
<h2>Mass (Kilograms/Pounds)</h2>
<p class="" id="output-el3"></p>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
I've annotated your css below. I've made your input div children block level elements so they appear on their own line. I've then added margin: auto to them to make them centered. I've aligned text to the center using text-align: center;
Alignment is always a PITA (much less so these days) but there's a handy tool to use to help you: howtocenterincss.com
* {
box-sizing: border-box;
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
padding: 2rem 1rem;
margin: 0 auto;
}
.converter-tab {
color: white;
background: #6943ff;
width: 550px;
height: 285px;
}
.converter-tab > * {
display: block; /* make each item a block element so it appears on its own line */
text-align: center; /* make text (e.g. inside <p> tags) centered */
margin-inline: auto; /* make block level elements centered */
}
.converter-input {
width: 117px;
height: 83px;
background: none;
border: solid 1px white;
color: white;
font-size: 2.5rem;
margin-bottom: 0.5rem; /*just added this to neaten it up a smidge */
}
.converter-btn {
width: 117px;
height: 42px;
border-radius: 5px;
border: none;
}
.output {
text-align: center; /* center the text in your output div */
background: #f4f4f4;
color: #5a537b;
width: 550px;
height: 400px;
}
.length,
.volume,
.mass {
width: 500px;
height: 108px;
background: #ffffff;
margin-bottom: 20px;
margin-top: 10px;
}
<div class="container">
<div class="converter-tab">
<h2>Metric/Imperial Unit Conversion</h2>
<input type="text" id="input-el" class="converter-input" />
<button class="converter-btn" id="convert-btn">Convert</button>
</div>
<div class="output">
<div class="length" id="length-el">
<h2>Length (Meter/Feet)</h2>
<p class="" id="output-el"></p>
</div>
<div class="volume" id="volume-el">
<h2>Volume (Liters/Gallons)</h2>
<p class="" id="output-el2"></p>
</div>
<div class="mass" id="mass-el">
<h2>Mass (Kilograms/Pounds)</h2>
<p class="" id="output-el3"></p>
</div>
</div>
</div>
As it's acceptably supported all over major browsers I'd use flex: just change the display mode of your container div to flex, set flex-direction: column; and justify-content: center;. After this adjust top and bottom padding as you prefer.
* {
box-sizing: border-box;
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
padding: 2rem 1rem;
margin: 0 auto;
}
.converter-tab {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
color: white;
background: #6943ff;
width: 550px;
height: 285px;
}
.converter-input {
width: 117px;
height: 83px;
background: none;
border: solid 1px white;
color: white;
font-size: 2.5rem;
}
.converter-btn {
width: 117px;
height: 42px;
border-radius: 5px;
border: none;
}
.output {
background: #f4f4f4;
color: #5a537b;
width: 550px;
height: 400px;
}
.length,
.volume,
.mass {
width: 500px;
height: 108px;
background: #ffffff;
margin-bottom: 20px;
margin-top: 10px;
}
<!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" />
<link rel="stylesheet" href="style.css" />
<title>Unit Conversion</title>
</head>
<body>
<div class="container">
<div class="converter-tab">
<h2>Metric/Imperial Unit Conversion</h2>
<input type="text" id="input-el" class="converter-input" />
<button class="converter-btn" id="convert-btn">Convert</button>
</div>
<div class="output">
<div class="length" id="length-el">
<h2>Length (Meter/Feeet)</h2>
<p class="" id="output-el"></p>
</div>
<div class="volume" id="volume-el">
<h2>Volume (Liters/Gallons)</h2>
<p class="" id="output-el2"></p>
</div>
<div class="mass" id="mass-el">
<h2>Mass (Kilograms/Pounds)</h2>
<p class="" id="output-el3"></p>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
I have an adminHeader.php as belows,
<div class="main_content">
<div style="width: 100%">
<div class="header" style="align-items: center;font-size: 17px;">
<a style=" text-decoration-line: none;">Dashboard</a>
<div>
<a href="#" name="age" id="age" data-toggle="modal" data-target="#add_data_Modal" > <img src="../assets/images/logo.png" width="35" height="35" style="vertical-align:middle"/> <?php echo htmlspecialchars($_SESSION["username"]); ?></a>
<i class="fa fa-toggle-left"></i> logout
</div>
</div>
I need to use this header on top of my page as follows,
So I implemented as follows,
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Anomaly Monitoring Dashboard</title>
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
</head>
<div class="wrapper">
<div class="sidebar">
<h2> Dashboard</h2>
<ul>
<li><i class="fa fa-home"></i> Home</li>
</ul>
</div>
<div class="main_content">
<?php
include "./adminHeader.php";
?>
</div>
</div>
</div>
But I can see the rendered HTMl as below,
And I need to scroll to see all the fields. Can someone help me to fit this to the screen? '
update:
Here is my css class.
*{
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
font-family: 'Josefin Sans', sans-serif;
}
.wrapper{
display: flex;
position: relative;
}
.wrapper .main_content{
width: 100%;
margin-left: 220px;
}
.wrapper .main_content .header{
padding: 20px;
background: #fff;
color: #717171;
border-bottom: 1px solid #e0e4e8;
display: flex;
justify-content: space-between;
position: relative;
}
.wrapper .main_content .info{
margin: 20px;
color: #717171;
line-height: 25px;
}
.wrapper .main_content .info div{
margin-bottom: 20px;
}
.error {
color: red;
}
.vega-actions {display: none}
h3 { font-family: 'Source Code Pro', sans-serif;
font-weight: 50;
font-size: 10px;
margin-top:0px;
display: block;
color: #404040;
text-align: right;
border-top:3px solid #000;
}
.card {
display: flex;
justify-content: center;
}
.flex {
display: flex;
justify-content: space-between;
}
Can someone show me what should I include in css file to show as I required?
try flexbox or grid layout
https://developer.mozilla.org/de/docs/Web/CSS/CSS_Grid_Layout
for flexbox layouts use the display: flex on the container and add flex-flow-column for a vertical flexible layout. Then set you width and heights to your needs, with flex-shrink: 0 for elements with fixed width or height.
.wrapper {
display: flex;
width: 100%;
height: 100%
}
.sidebar {
width: <sidebar width>;
display: block;
height: 100%;
flex-shrink: 0;
}
.main-content {
width: calc(100% - <sidebar width>);
display: block | <or flex or grid, ...>;
}
So as you can see on this image:
I want to make a page design as above, but I can not place the checkboxes like on the picture (centered, under it's right times, above it's spaces)
Currently I am here:
body {
background-color: gray;
}
#head {
padding-top: 20px;
text-align:center;
display:block;
}
#container {
background-color: #1b345e;;
}
h2 {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
background-color: #1b345e;
color: white;
}
.topnav {
position: relative;
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.topnav a.active {
background-color: #4CAF50;
color: white;
}
/* Centered section inside the top navigation */
.topnav-centered a {
float: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* Right-aligned section inside the top navigation */
.topnav-right {
float: right;
}
input {
margin-left: 49%;
width: 30px;
height: 30px;
}
.checkboxes{
display: inline;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Piarista Kollégium - Stúdiumi jelentkezés</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<div id="container">
<div class="topnav">
<div class="topnav-centered">
Jelentkezés
</div>
Frissítések
<div class="topnav-right">
Bejelentkezés
</div>
</div>
<div id="head">
<img src="logo.png">
</div>
<h2>Üdvözöllek, XY!</h2>
</div>
<div class="checkboxes">
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
<div>
<h4>14:30-15:15</h4>
<input type="checkbox">
</div>
</div>
</body>
</html>
But as you can see, I am not doing it the right way. Can someone help me or explain me how I could place my elements like on the picture?
(The header part is finished)
Center the elements using flexbox and use justify-content: center to align them.
.checkboxes {
display: flex;
flex-wrap: wrap;
width: 100%;
justify-content: center;
}
.checkboxes div {
text-align: center;
margin: 0 10px;
}
Here is a working example: https://codepen.io/dobladov/pen/pqqypY
I have searched and tweek around and the last image still shows up very close to the second. This is a very simple responsive web layout that, for some mistake, it is not displaying properly. this keeps asking me for more details but I have no more details to give.
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #f4f4f4;
}
/* Global */
.container {
widows: 80%;
margin: auto;
overflow: hidden;
}
ul {
margin: 0;
padding: 0;
}
.button_1 {
height: 38px;
background: #e8491d;
border: none;
padding-left: 20px;
padding-right: 20px;
color: #ffffff;
}
/* Header */
header {
background: #35424a;
color: #ffffff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 4px solid;
}
header a {
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: left;
display: inline;
padding: 0 20px 0 20px;
}
header #branding {
float: left;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 12px;
}
header .current a {
color: #e8491d;
font-weight: bold;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
/* Showcase */
#showcase {
min-height: 400px;
background: url('../Assets/for\ rent.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
text-align: center;
color: #3433FF;
}
#showcase h1 {
margin-top: 100px;
font-size: 55px;
margin-bottom: 10px;
}
#showcase p {
font-size: 20px;
}
/* For Tenants */
#cozy {
padding: 15px;
background: #35424a;
}
.button_1 {
float: right;
margin-top: 15px;
}
/*Boxes*/
#boxes {
margin-top: 20px;
}
#boxes .box {
float: left;
text-align: center;
width: 30%;
padding: 10px;
}
#main {
margin-top: 20px;
}
#main .box {
float: left;
text-align: center;
width: 33%;
padding: 10px;
display: inline-block;
}
#main .box assets {
width: 100px;
}
/*Footer*/
footer {
padding: 20px;
margin-top: 20px;
color: #ffffff;
background-color: #e8491d;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<meta name="description" content="Properties for lease">
<meta name="keywords" content="lakeland, oldsmar, lutz">
<meta name="author" content="SAGS PROPERTIES LLC">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>SAGS PROPERTIES</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="./css/style.css" />
<script src="main.js"></script>
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1><span>SAGS Properties LLC</span></h1>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Lutz</li>
<li>Oldsmar</li>
<li>Lakeland</li>
</ul>
</nav>
</div>
</header>
<section id="showcase">
<div class="container">
<h1>Well Managed Properties</h1>
<p>In Lutz, Oldsmar and Lakeland</p>
</div>
</section>
<section id="cozy">
<div class="container">
<button type="submit" class="button_1">Tenants Click Here</button>
</div>
</section>
<section id="boxes">
<div class="container">
<div class="box">
<img src="./Assets/Entrance Lutz.jpg">
<h3>Lutz</h3>
<p>Lakeview at Calusa Trace</p>
</div>
<div class="container">
<div class="box">
<img src="./Assets/Entrance Lakeland.jpg">
<h3>Lakeland</h3>
<p>Cobblestone Landing</p>
</div>
<div class="container">
<div class="box">
<img src="./Assets/Entrance Oldsmar.jpg">
<h3>Oldsmar</h3>
<p>Gardens at Forrest Lakes</p>
</div>
</div>
</section>
<footer>
<p>SAGS PROPERTIES LLC © 2018</p>
</footer>
</body>
</html>
There are no more details to give. Making a question is as frustrating as learning this!!!
This question already has answers here:
Button Center CSS
(7 answers)
Closed 4 years ago.
I've tried so many solutions, it's giving me a headache!
* {
box-sizing: border-box;
}
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
background-color: #fff;
}
/* Global */
.container {
width: 100%;
margin: auto;
overflow: hidden;
border: 1px solid red;
}
button {
background-color: #ff5f49;
border: none;
padding: 15px;
color: #fff;
font-size: 1.2em;
}
/* Navigation */
header {
background-color: #353c42;
min-height: 75px;
text-align: center;
font-size: 1.3em;
}
nav ul li {
display: inline;
padding: 15px;
text-align: center;
}
nav ul li a {
text-decoration: none;
text-transform: uppercase;
color: #fff
}
/* Jumbotron */
#jumbotron {
}
#jumbotron img {
display: block;
width: 60%;
margin: auto;
margin-top: 80px;
}
.button-1 {
width: 20%;
display: inline-block;
margin: 0 auto;
}
/* Clearfix */
.clearfix::after {
content: "";
clear: both;
display: table;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="description" content="Digital Creative Agency Melbourne">
<meta name="keywords" content="Creative Agency Melbourne">
<meta name="author" content="KreativeZ">
<title>KreativeZ | Creative Agency Melbourne</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header>
<div class="container">
<nav>
<ul>
<li>Home</li>
<li>Services</li>
<li>Our Work</li>
<li>Contact</li>
</ul>
</nav>
</div>
</header>
<section id="jumbotron">
<div class="container">
<img src="img/KreativeZ_logo.png" alt="KreativeZ Logo">
<div class="container">
<button class="button-1" type="button">Get in touch!</button>
<button class="button-1" type="button">See Our Work</button>
</div>
</div>
</div>
</section>
</body>
</html>
Add ' text-align: center;' to the container.
* {
box-sizing: border-box;
}
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
background-color: #fff;
}
/* Global */
.container {
width: 100%;
margin: auto;
overflow: hidden;
border: 1px solid red;
text-align: center;
}
button {
background-color: #ff5f49;
border: none;
padding: 15px;
color: #fff;
font-size: 1.2em;
}
/* Navigation */
header {
background-color: #353c42;
min-height: 75px;
text-align: center;
font-size: 1.3em;
}
nav ul li {
display: inline;
padding: 15px;
text-align: center;
}
nav ul li a {
text-decoration: none;
text-transform: uppercase;
color: #fff
}
/* Jumbotron */
#jumbotron {
}
#jumbotron img {
display: block;
width: 60%;
margin: auto;
margin-top: 80px;
}
.button-1 {
width: 20%;
display: inline-block;
margin: 0 auto;
}
/* Clearfix */
.clearfix::after {
content: "";
clear: both;
display: table;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="description" content="Digital Creative Agency Melbourne">
<meta name="keywords" content="Creative Agency Melbourne">
<meta name="author" content="KreativeZ">
<title>KreativeZ | Creative Agency Melbourne</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header>
<div class="container">
<nav>
<ul>
<li>Home</li>
<li>Services</li>
<li>Our Work</li>
<li>Contact</li>
</ul>
</nav>
</div>
</header>
<section id="jumbotron">
<div class="container">
<img src="img/KreativeZ_logo.png" alt="KreativeZ Logo">
<div class="container">
<button class="button-1" type="button">Get in touch!</button>
<button class="button-1" type="button">See Our Work</button>
</div>
</div>
</div>
</section>
</body>
</html>
You might add display:flex and justify-content:center to the container of your buttons:
* {
box-sizing: border-box;
}
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
background-color: #fff;
}
/* Global */
.container {
width: 100%;
margin: auto;
overflow: hidden;
border: 1px solid red;
}
.container .container{
display:flex;
justify-content: center;
}
button {
background-color: #ff5f49;
border: none;
padding: 15px;
color: #fff;
font-size: 1.2em;
}
/* Navigation */
header {
background-color: #353c42;
min-height: 75px;
text-align: center;
font-size: 1.3em;
}
nav ul li {
<header>
<div class="container">
<nav>
<ul>
<li>Home</li>
<li>Services</li>
<li>Our Work</li>
<li>Contact</li>
</ul>
</nav>
</div>
</header>
<section id="jumbotron">
<div class="container">
<img src="img/KreativeZ_logo.png" alt="KreativeZ Logo">
<div class="container">
<button class="button-1" type="button">Get in touch!</button>
<button class="button-1" type="button">See Our Work</button>
</div>
</div>
</div>
</section>