I need to create something like the image below, without using any frameworks like bootstrap. Basically, I need the image to not be full width, but to take say 80% of the screen, and the title of the webpage to be above that image. At the moment all of my content is flowing all around the page.
It should also remain the same when I make the screen smaller.
I don't know why something simple is just not working for me...
.container {
width: 100%;
}
}
#main {
background: red;
width: 80%;
margin: 0 auto;
}
img {
max-width: 100%;
width: 80%;
float: right;
display: block;
}
<div id='main'>
<div class='container'>
<!--Image-->
<div id='img-div'>
<img id='image' src='https://www.projectarm.com/wp-content/uploads/2018/01/Frida-Kahlo-Vogue-1939-New-York-foto-di-Nickolas-Murray-2.jpg' />
<div id='img-caption'>This is a caption for the image</div>
</img>
</div>
<!--Title-->
<div id='pagetitle'>
<h1 id='title'>Frida Kahlo</h1>
<span id='tagline'>A short Tribute</span>
</div>
<!--End Title-->
</div>
<div id='tribute-info'>
This is my main information about the person
This is a link for more information
</div>
I would use flex for your container, so you can swap the order and it is a more up to date way to position things than floating, then inline block for your tag lines
Please note your image tag is invalid - img tags are self closing
.container {
width: 100%;
display: flex; /* make the container flex */
flex-direction: row; /* align the children in a row */
}
#img-div {
max-width: 85%; /* 85% width */
flex-basis: 85%;
order: 2; /* put this div 2nd */
}
#image {
display: block;
width: 100%; /* make div stretch size of div */
}
#pagetitle {
box-sizing: border-box; /* make this div 15% width with a bit of padding */
padding: 20px;
max-width: 15%;
flex-basis: 15%;
order: 1; /* put this div 1st */
display: flex; /* make this flex for vertical aligning and align children in a column */
flex-direction: column;
justify-content: center; /* vcertical align center (only works with flex) */
overflow: visible; /* show overflow */
position: relative; /* make overflow appear on top of image */
z-index: 2;
}
#title {
font-size: 20px;
font-weight: normal;
}
.tag-holder {
position: relative;
}
.tagline {
display: inline-block; /* make inline block so you can add white background */
white-space: nowrap;
font-size: 30px;
font-weight: bold;
text-transform: uppercase;
background: white;
padding:0.1em 0.5em;
}
<div id='main'>
<div class='container'>
<!--Image-->
<div id='img-div'>
<img id='image' src='https://www.projectarm.com/wp-content/uploads/2018/01/Frida-Kahlo-Vogue-1939-New-York-foto-di-Nickolas-Murray-2.jpg' />
</div>
<!--Title-->
<div id='pagetitle'>
<h1 id='title'>Emilia<br>Cole</h1>
<div class="tag-holder">
<span class='tagline'>Twist</span>
<span class='tagline'>in my</span>
<span class='tagline'>reality</span>
</div>
</div>
<!--End Title-->
</div>
<div id='tribute-info'>
This is my main information about the person
This is a link for more information
</div>
Without flex:
.container {
width: 100%;
position: relative;
}
.container:after {
content: '';
display: block;
height: 0;
clear: both;
overflow: hidden;
}
#img-div {
width: 85%;
/* 85% width */
float: right;
}
#image {
display: block;
width: 100%;
/* make div stretch size of div */
}
#pagetitle {
position:absolute; /* this is for 100% height */
top:0; bottom:0;
left:0;
right:15%;
overflow: visible;
z-index: 2;
}
.center { /* center text vertically */
position:absolute;
top:50%;
left:20px;
transform:translateY(-50%);
}
#title {
font-size: 20px;
font-weight: normal;
margin-top:0;
}
.tag-holder {
position: relative;
}
.tagline {
display: inline-block;
/* make inline block so you can add white background */
white-space: nowrap;
font-size: 30px;
font-weight: bold;
text-transform: uppercase;
background: white;
padding: 0.1em 0.5em;
}
<div id='main'>
<div class='container'>
<!--Image-->
<div id='img-div'>
<img id='image' src='https://www.projectarm.com/wp-content/uploads/2018/01/Frida-Kahlo-Vogue-1939-New-York-foto-di-Nickolas-Murray-2.jpg' />
</div>
<!--Title-->
<div id='pagetitle'>
<div class="center">
<h1 id='title'>Emilia<br>Cole</h1>
<div class="tag-holder">
<span class='tagline'>Twist</span><br>
<span class='tagline'>in my</span><br>
<span class='tagline'>reality</span>
</div>
</div>
</div>
<!--End Title-->
</div>
<div id='tribute-info'>
This is my main information about the person
This is a link for more information
</div>
Try this image caption is placed on top
.container {
width: 100%;
}
}
#main {
background: red;
width: 80%;
margin: 0 auto;
}
img {
max-width: 100%;
width: 80%;
float: right;
display: block;
}
#img-caption{
position: absolute;
left: 50%;
margin-left: -50px; /* margin is -0.5 * dimension */
}
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tribute Page</title>
</head>
<body>
<div id='main'>
<div class = 'container'>
<!--Image-->
<div id='img-div'>
<img id='image' src='https://www.projectarm.com/wp-content/uploads/2018/01/Frida-Kahlo-Vogue-1939-New-York-foto-di-Nickolas-Murray-2.jpg'/>
<div id='img-caption' class='alert alert-info'>This is a caption for the image</div>
</div>
<!--Title-->
<div id='pagetitle'>
<h1 id='title'>Frida Kahlo</h1>
<span id ='tagline'>A short Tribute</span>
</div>
<!--End Title-->
</div>
<div id ='tribute-info'>
This is my main information about the person
This is a link for more information
</div>
</div>
</body>
</html>
I was able to solve it simply by giving my container element a relative positioning, and my title #pagetitle element an absolute positioning, and then positioning the title top: 30px and left 30px RELATIVE to my container element. In this way, my title was positioned relative to the container, and not to the page - which would otherwise be the case had I not given the relative positioning to the container of the title.
.container {
height: 90vh;
min-height: 410px;
margin-top: 40px;
position: relative;
}
#pagetitle {
font-size: 2em;
text-transform: uppercase;
letter-spacing: 0.3em;
position: absolute;
top: 30px;
left: 30px;
}
I also gave a height to my container to make sure the content won't flow around it.
This can be easily done with CSS Grid, which is a more modern technology as well, but I preferred to stick to the traditional positioning to learn and fully understand them before skipping steps and using the easier grid system.
Whole pen and result can be seen here: https://codepen.io/commiesar/pen/GBMLza?editors=1100
Related
My goal: A responsive navbar where the logo is always in the middle and an element
is always on the left. Depending on the context (page dependent), buttons can be
displayed in the right area or not.
My approach: I use a flexbox for the navbar. I have three divs in the flexbox. I have given all divs a fixed width. The middle box is also a flexbox. The div with a logo is located there. I position the logo on the right edge of the middle flexbox. The div with the logo has a fixed width (80px).
The problem: The approach works but I don't find this way very nice. Because the widths are dependent on each other. If you would change the logo and it would be wider or narrower then you would have to adjust the relative width of the middle and right box. The second problem is if the device smaller as 900px then this solution dont work.
Question: What other possibilities are there and what possibilities would resolve this "width" dependency?
#app {
margin: 0 auto;
max-width: 900px;
width:100%;
}
header {
height: 80px;
display: flex;
justify-content:space-between;
}
.header-left {
width:20%;
background: green;
}
.header-middle {
width:34%;
background: gray;
display: flex;
justify-content:flex-end;
}
.header-right {
width:46%;
background: green;
}
.logo {
background-color: red;
width:80px;
height: 80px;
text-align:center;font-size:70px;
}
<div id="app">
<small>width: 900px</small>
<header>
<div class="header-left">Burger Menu</div>
<div class="header-middle">
<div class="logo">
I
</div>
</div>
<div class="header-right">Context Buttons</div>
</header>
<div>
<div style="width:50%; background: black;color:white; text-align:center;">Controller Div 50%</div>
</div>
</div>
You can use flex-grow: 1 on the left and right elements, the middle element will be in center naturally. In this case, you don't need to set widths on elements.
#app {
margin: 0 auto;
max-width: 900px;
width:100%;
}
header {
height: 80px;
display: flex;
justify-content:space-between;
}
.header-left {
flex-grow: 1;
background: green;
}
.header-middle {
background: gray;
display: flex;
justify-content:flex-end;
}
.header-right {
flex-grow: 1;
background: green;
}
.logo {
background-color: red;
width:80px;
height: 80px;
text-align:center;font-size:70px;
}
<div id="app">
<small>width: 900px</small>
<header>
<div class="header-left">Burger Menu</div>
<div class="header-middle">
<div class="logo">
I
</div>
</div>
<div class="header-right">Context Buttons</div>
</header>
<div>
<div style="width:50%; background: black;color:white; text-align:center;">Controller Div 50%</div>
</div>
</div>
Since you're looking for different possibilities i'll suggest you to take the approch used by Tepken Vannkorn :
Centering brand logo in Bootstrap Navbar
Based on your comments, I would suggest the following code as a simple solution.
I have added a max-width value to your .logo CSS class and I have also moved your inline CSS from the front-end code, and created a .controller CSS class for it.
#app {
margin: 0 auto;
max-width: 900px;
width: 100%;
}
header {
height: 80px;
display: flex;
justify-content: space-between;
}
.header-left {
width: 20%;
background: green;
}
.header-middle {
width: 34%;
background: gray;
display: flex;
justify-content: flex-end;
}
.header-right {
width: 46%;
background: green;
}
.logo {
background-color: red;
width: 80px;
height: 80px;
text-align: center;
font-size: 70px;
max-width: 80px;
}
.controller {
width: 50%;
background: black;
color: white;
text-align: center;
}
<div id="app">
<small>width: 900px</small>
<header>
<div class="header-left">Burger Menu</div>
<div class="header-middle">
<div class="logo">
I
</div>
</div>
<div class="header-right">Context Buttons</div>
</header>
<div>
<div class="controller">Controller Div 50%</div>
</div>
</div>
A solution would be to use a mix of flex and position: absolute. Then you need only the left and the right container. the logo you can center with position left: left: calc(50% - calc(80px / 2));. The 80px is the width from your logo.
* {
margin: 0;
padding: 0;
}
#app {
margin: 0 auto;
max-width: 900px;
width:100%;
}
.header {
display: flex;
justify-content: space-between;
height: 80px;
background: yellow;
position: relative;
}
.header-left {
background-color: green;
width: 20%
}
.header-right {
background-color: green;
width: 44%;
}
.logo {
background-color: red;
width:80px;
height: 80px;
text-align:center;
font-size:70px;
position: absolute;
left: calc(50% - calc(80px / 2));
}
<div id="app">
<div class="header">
<div class="header-left">left</div>
<div class="logo">X</div>
<div class="header-right">right</div>
</div>
<div style="width:50%; background: black;">Controller Div 50%</div>
</div>
I'm trying to customize my blog layout by adding a sticky sidebar. I managed to get position:sticky to work as excepted, but I can't figure out how to position the blocks where I want.
I want the main block to be centered, and the sidebar right beside the main block. here's an example of what I'm aiming for: https://theme-next.js.org/ except I want the main block to be centered.
this is the layout I want
I've tried using margin-left with the sidebar, but it doesn't work well in smaller windows, as the left margin is constant and pushes the real content away in smaller windows.
this is what happens by using margin-left
(I'm not sure why the sticky dosen't work here, but it works fine on my website. All I'm trying to figure out is how to position them where I want.
.wrapper {
display: flex;
justify-content: space-between;
}
.sidebar {
width: 80px;
background-color: #FF0000;
position: webkit-stiky;
position: sticky;
align-self: flex-start;
height: 1000px;
}
.main {
width: 100px;
background-color: #CFCFCF;
margin: auto;
height: 1600px;
}
.header {
background-color: #F3FF00;
width: 150px;
margin: auto;
}
<div class="header">
<p>
this is centered header
</p>
</div>
<div class="wrapper">
<div class="sidebar">
<p> sidebar here</p>
</div>
<div class="main">
<p>
I want this block to be centered;
</p>
</div>
</div>
There's a few things you need to do here:
Set a top property for your sticky sidebar, or it won't stick
Make your main element a flex parent since we'll need to offset its child element to make it centered with your header.
Create an inner element for your main element so you can move it to the left 80px to accommodate for the sidebar width.
.wrapper {
display: flex;
position: relative;
}
.sidebar {
width: 80px;
height: 1000px;
background-color: #FF0000;
position: sticky;
/* you need a top position set for sticky */
top: 0;
}
.main {
height: 1600px;
background-color: #eeeeee;
/* This needs to be a flex parent */
display: flex;
justify-content: center;
/* This element needs to be 100% MINUS the sidebar width of 80px */
flex: 1 0 calc(100% - 80px);
}
.main-inner {
width: 100px;
position: relative;
background-color: #CFCFCF;
/* Move the inner element 80px to the left */
margin-left: -80px;
text-align: center;
}
.header {
background-color: #F3FF00;
width: 150px;
margin: 0 auto;
}
<div class="header">
<p>this is centered header</p>
</div>
<div class="wrapper">
<div class="sidebar">
<p>sidebar here</p>
</div>
<div class="main">
<div class="main-inner">
<p>I want this block to be centered;</p>
</div>
</div>
</div>
However, I believe this is what you really want:
Make the header a flex parent as well.
.wrapper {
display: flex;
position: relative;
}
.sidebar {
width: 80px;
height: 1000px;
background-color: #FF0000;
position: sticky;
/* you need a top position set for sticky */
top: 0;
}
.main {
height: 1600px;
background-color: #eeeeee;
/* This needs to be a flex parent */
display: flex;
justify-content: center;
/* This element needs to be 100% MINUS the sidebar width of 80px */
flex: 1 0 calc(100% - 80px);
}
.main-inner {
width: 100px;
position: relative;
background-color: #CFCFCF;
/* Move the inner element 80px to the left */
text-align: center;
}
.header {
display: flex;
justify-content: flex-end;
}
.header-inner {
background-color: #F3FF00;
text-align: center;
width: calc(100% - 80px);
background-color: #F3FF00;
}
<div class="header">
<div class="header-inner">
<p>this is centered header</p>
</div>
</div>
<div class="wrapper">
<div class="sidebar">
<p>sidebar here</p>
</div>
<div class="main">
<div class="main-inner">
<p>I want this block to be centered;</p>
</div>
</div>
</div>
I have just started of with HTML so this is a new realm for me. I am trying to get a rectangular container in the middle of the pafe,Overlaying two other containers. This is the script i wrote and this how i am trying to make it look like
<style>
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height:800px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
img {
width:100%;
height:100%;
}
.footer {
clear:both;
font-family: 'McLaren', cursive;
background-color:black;
text-align:center;
height:50px;
padding-top: 10px;
box-sizing: border-box;
}
</style>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h2>Two Equal Columns</h2>
<div class="row">
<div class="column" style="background-color:#aaa;">
<img src="4.jpg"alt="Snow">
</div>
<div class="column" style="background-color:#bbb;">
<img src="5.jpg"alt="Snow">
</div>
<div class="footer">
© These are random text
</div>
</div>
</body>
</html>
This is what i am trying to get it to look like
Add position:relative to your row Class. This way the orange block can be positioned in the middle of the two .column divs
And then add this css class to the div you want to center
.middleScreen {
position:absolute;
top: 50%;
left: 50%;
width : 100px ;
height : 100px ;
background-color : orange ;
margin-top: -50px; /* = - 1/2 of the height*/
margin-left: -50px; /* = - 1/2 of the width*/
}
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height:800px;
}
.row {
position :relative;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
img {
width:100%;
height:100%;
}
.footer {
clear:both;
font-family: 'McLaren', cursive;
background-color:black;
text-align:center;
height:50px;
padding-top: 10px;
box-sizing: border-box;
}
.middleScreen {
position:absolute;
top: 50%;
left: 50%;
width : 100px ;
height : 100px ;
background-color : orange ;
margin-top: -50px; /* = - 1/2 of the height*/
margin-left: -50px; /* = - 1/2 of the width*/
}
<h2>Two Equal Columns</h2>
<div class="row">
<div class="column" style="background-color:#aaa;">
<img src="4.jpg"alt="Snow">
</div>
<div class="column" style="background-color:#bbb;">
<img src="5.jpg"alt="Snow">
</div>
<div class="footer">
© These are random text
</div>
<div class="middleScreen">
aaaaaaaaaaa
</div>
</div>
You can try using absolute position.
Example : if you’re div is 50% of the screen width and height etc.
.div{
position: absolute;
top: 25%;
left: 25%;
}
<style>
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.row{
display: flex;
justify-content: center;
align-items: center;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
img {
width:100%;
height:100%;
}
.footer {
position: fixed;
font-family: 'McLaren', cursive;
background-color: black;
text-align: center;
height: 50px;
padding-top: 10px;
box-sizing: border-box;
width: 100%;
bottom: 0;
}
</style>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h2>Two Equal Columns</h2>
<div class="row">
<div class="column" style="background-color:#aaa;">
<img src="4.jpg"alt="Snow">
</div>
<div class="column" style="background-color:#bbb;">
<img src="5.jpg"alt="Snow">
</div>
</div>
<div class="footer">
© These are random text
</div>
</body>
</html>
Hope this code will help you:
body
{
padding:0;
margin:0;
}
.row
{
width: 100%;
height: 100vh;
display: flex;
position: relative;
}
.column
{
width: 50%;
height: 100%;
}
.column img
{
width: 100%;
height: 100%;
object-fit: cover;
}
.yellow
{
background-color: #ff0;
}
.red
{
background-color: #f00;
}
.overlay
{
width: 30%;
height: 30%;
box-sizing: border-box;
padding: 2rem;
background-color: #00f;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
<section class="row">
<div class="column yellow">
<img src="" alt="">
</div>
<div class="column red">
<img src="" alt="">
</div>
<div class="overlay">
<h1>Hello word!</h1>
</div>
</section>
I have 2 divs (.showcase, .highlight) nested inside an element with position: relative:
I would like to have a margin on the left of the .contentContainer for the navigation menu (23.79%). Then I would like 2 divs inside the contentContainer div that extend the whole height of the screen, regardless of their content. Then I would like to add content inside those two divs.
<div id="App">
<div data-reactroot="">
<div class="navbarContainer">
</div>
<div class="contentContainer">
<div class="showcase">
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
</div>
<div class="highlight"></div>
</div>
</div>
</div>
Now when I add more divs into my showcase div, the .showcase div gets moved to the bottom of the screen (so only the 100px of the .thumb divs are visible.). I can't figure out what I am doing wrong.
Stylesheet:
#App {
background-color: #fff;
color: $fontC2;
font-family: 'Roboto';
min-height: 100vh;
min-width: 320px;
position: relative;
}
.contentContainer {
margin-left: 23.79%;
width: 76.21%;
height: 100vh;
.showcase {
width: 61%;
height: 100vh;
display: inline-block;
background-color: red;
top: 0;
.thumb {
width: 20%;
height: 100px;
background-color: $primaryC3;
display: inline-block;
}
}
.highlight {
width: 39%;
background-color: $primaryC2;
height: 100vh;
display: inline-block;
}
}
Fiddle here:
https://jsfiddle.net/2tz9940v/
I want the Content A, Content B, and Content C columns to be horizontally centered. I have this code been trying to add
http://jsfiddle.net/hsX5q/24/
HTML:margin: 0 auto to .columns-container and it doesn't work. Could anyone help?
/*************************
* Sticky footer hack
* Source: http://pixelsvsbytes.com/blog/2011/09/sticky-css-footers-the-flexible-way/
************************/
/* Stretching all container's parents to full height */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
/* Setting the container to be a table with maximum width and height */
#container {
display: table;
height: 100%;
width: 100%;
}
/* All sections (container's children) should be table rows with minimal height */
.section {
display: table-row;
height: 1px;
}
/* The last-but-one section should be stretched to automatic height */
.section.expand {
height: auto;
}
/*************************
* Full height columns
************************/
/* We need one extra container, setting it to full width */
.columns-container {
display: table-cell;
height: 100%;
width: 300px;
margin: 0 auto;
}
/* Creating columns */
.column {
/* The float:left won't work for Chrome for some reason, so inline-block */
display: inline-block;
/* for this to work, the .column elements should have NO SPACE BETWEEN THEM */
vertical-align: top;
height: 100%;
width: 100px;
}
/****************************************************************
* Just some coloring so that we're able to see height of columns
****************************************************************/
header {
background-color: yellow;
}
#a {
background-color: pink;
}
#b {
background-color: lightgreen;
}
#c {
background-color: lightblue;
}
footer {
background-color: purple;
}
<div id="container">
<header class="section">
foo
</header>
<div class="section expand">
<div class="columns-container">
<div class="column" id="a">
<p>Contents A</p>
</div>
<div class="column" id="b">
<p>Contents B</p>
</div>
<div class="column" id="c">
<p>Contents C</p>
</div>
</div>
</div>
<footer class="section">
bar
</footer>
</div>
If you add text-align: center to the declarations for .columns-container then they align centrally:
.columns-container {
display: table-cell;
height: 100%;
width:600px;
text-align: center;
}
/*************************
* Sticky footer hack
* Source: http://pixelsvsbytes.com/blog/2011/09/sticky-css-footers-the-flexible-way/
************************/
/* Stretching all container's parents to full height */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
/* Setting the container to be a table with maximum width and height */
#container {
display: table;
height: 100%;
width: 100%;
}
/* All sections (container's children) should be table rows with minimal height */
.section {
display: table-row;
height: 1px;
}
/* The last-but-one section should be stretched to automatic height */
.section.expand {
height: auto;
}
/*************************
* Full height columns
************************/
/* We need one extra container, setting it to full width */
.columns-container {
display: table-cell;
height: 100%;
width:600px;
text-align: center;
}
/* Creating columns */
.column {
/* The float:left won't work for Chrome for some reason, so inline-block */
display: inline-block;
/* for this to work, the .column elements should have NO SPACE BETWEEN THEM */
vertical-align: top;
height: 100%;
width: 100px;
}
/****************************************************************
* Just some coloring so that we're able to see height of columns
****************************************************************/
header {
background-color: yellow;
}
#a {
background-color: pink;
}
#b {
background-color: lightgreen;
}
#c {
background-color: lightblue;
}
footer {
background-color: purple;
}
<div id="container">
<header class="section">
foo
</header>
<div class="section expand">
<div class="columns-container">
<div class="column" id="a">
<p>Contents A</p>
</div>
<div class="column" id="b">
<p>Contents B</p>
</div>
<div class="column" id="c">
<p>Contents C</p>
</div>
</div>
</div>
<footer class="section">
bar
</footer>
</div>
This does, though, require that you reset the .column elements to text-align: left (assuming you want them left-aligned, obviously (JS Fiddle demo).
Sometimes you have things other than text inside a table cell that you'd like to be horizontally centered. In order to do this, first set up some css...
<style>
div.centered {
margin: auto;
width: 100%;
display: flex;
justify-content: center;
}
</style>
Then declare a div with class="centered" inside each table cell you want centered.
<td>
<div class="centered">
Anything: text, controls, etc... will be horizontally centered.
</div>
</td>
Short snippet for future visitors - how to center horizontal table-cell (+ vertically)
html, body {
width: 100%;
height: 100%;
}
.tab {
display: table;
width: 100%;
height: 100%;
}
.cell {
display: table-cell;
vertical-align: middle;
text-align: center; /* the key */
background-color: #EEEEEE;
}
.content {
display: inline-block; /* important !! */
width: 100px;
background-color: #00FF00;
}
<div class="tab">
<div class="cell">
<div class="content" id="a">
<p>Content</p>
</div>
</div>
</div>
Just add this class in your css
.column p{
text-align:center;
}