I'm trying to align a title element with the second column of the content below. A visual example would be:
Here you can see that the title aligns nicely with the content below. Applying a margin the same size as the numbers below + padding etc. would also work but I want the size of the first column below to shrink on tighter screens - generally thinking of using flexbox for the actual table content.
I could use a table and insert the title as the second column of the first row, but this is misusing tables.
Here is my code using flexbox for the items and li::before for the numbers.
https://jsfiddle.net/4dnLu836/1/
<div class="tbl-header">
<h3>Agenda</h3>
<div>Time: 30 mins</div>
</div>
<ol class="numbered">
<li>
<div class="item">Agenda Item 1</div>
<div class="time">10 mins</div>
</li>
<li>
<div class="item">Agenda Item 2</div>
<div class="time">20 mins</div>
</li>
</ol>
SCSS:
.tbl-header {
display: flex;
justify-content: space-between;
align-items: center;
h3 {
margin-left: calc(24px + 1em)
}
}
ol.numbered {
list-style: none;
counter-reset: counter1;
padding: 0;
li {
margin: 1em 0;
display: flex;
align-items: center;
counter-increment: counter1;
.item {
margin-left: 1em;
flex: 1 1 auto;
}
.time {
flex: 0 0 auto;
}
}
li::before {
content: counter(counter1);
background: red;
width: 24px;
height: 24px;
font-size: 18px;
line-height: 24px;
border-radius: 50%;
display: inline-block;
color: white;
text-align: center;
font-weight: normal;
font-stretch: normal;
font-style: normal;
letter-spacing: normal;
}
}
Note: the problem above is that I am having to define a fixed margin: 1em on the inner item and the agenda title.
Thanks
Iain
Ok. I think I ended up finding something that works. The margin is percentage based and therefore it isn't fixed but still lines up.
https://jsfiddle.net/gdvcpfqu/
<div class="tbl-header">
<h3>Agenda</h3>
<div>Time: 30 mins</div>
</div>
<ol class="numbered">
<li>
<div class="index">1</div>
<div class="item">Agenda Item 1</div>
<div class="time">10 mins</div>
</li>
<li>
<div class="index">2</div>
<div class="item">Agenda Item 2</div>
<div class="time">20 mins</div>
</li>
</ol>
SCSS
.tbl-header {
display: flex;
justify-content: space-between;
align-items: center;
h3 {
margin: 0 calc(24px + 2%)
}
}
ol.numbered {
list-style: none;
counter-reset: counter1;
padding: 0;
li {
margin: 1em 0;
display: flex;
align-items: center;
.item {
margin-left: 2%;
flex: 1 1 auto;
}
.time {
flex: 0 0 auto;
}
.index {
background: red;
max-width: 24px;
width: 24px;
height: 24px;
font-size: 18px;
line-height: 24px;
border-radius: 50%;
display: inline-block;
color: white;
text-align: center;
font-weight: normal;
font-stretch: normal;
font-style: normal;
letter-spacing: normal;
}
}
}
Related
This is my code for an auto showroom that's in development:
https://jsfiddle.net/zoh03cdv/
I have two problems.
First problem is getting images and text next to each other despite the fact I set contentbox1 to 2 columns:
* {
width: 890px;
}
a {
text-decoration: none;
}
header{
margin: 0; padding: 2em 5em 4em; color: #efefef;
overflow:hidden;
position: relative;
}
header::after{
content:"";
position:absolute;
top:0;
left:0;
height: 100%;
width:100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
font-family: sans-serif;
font-size: 16px;
width: 460px;
}
ul.vehicleinfo {
display: flex;
flex: 1 0 15%;
flex-grow: 3;
flex-wrap: wrap;
flex-basis: 100%;
width: 800px;
margin-left: 16px;
list-style: none;
margin: 3px;
justify-content: space-between;
}
ul.vehicleinfo li {
font-family: sans-serif;
font-size: 88%;
color: #333;
background-color: yellow;
margin-bottom: 10px;
width: 400px;
margin-right: 40px;
margin: 0 0 40px 0;
justify-content: flex-end;
}
ul.vehicleinfo li * {
display: block;
}
ul.vehicleinfo li h3 {
font-size: 1.2em;
}
div.autocontent {
width: 760px;
margin-left: 70px;
}
.price {
width: 550px;
text-align: center;
}
.contentbox1 {
column-span: 2;
}
.autoimg img {
width: 340px;
}
.descript1 {
font-size: 14px;
float: left;
}
<div class="autocontent">
<ul class="vehicleinfo">
<li><h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS WITH EVERY EXTRA</h3></li>
<li><h3 class="price">£36,500</h3></li>
</ul>
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
<div class="descript1">gold, 24,000 miles</div>
</div>
</div>
The text gets cut off and doesn't go on to another line as I expected: https://i.stack.imgur.com/tQMGN.jpg
I'm trying to get things evenly aligned having done this as a DIV and LI within DIVs.
Any help is appreciated to get this code looking more esthetically pleasing, it's working partially but the div part isn't the easiest, at least for anything contained within the class autocontent.
My problem is getting the columns to work properly.
For more proper UI layout and UX.
Try to update your HTML and CSS with following code
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
font-family: sans-serif;
font-size: 16px;
width: 460px;
}
ul.vehicleinfo {
display: block;
list-style: none;
padding: 0 10px;
}
ul.vehicleinfo li {
font-family: sans-serif;
font-size: 88%;
color: #333;
margin: 0;
padding: 5px 0;
border-radius: 10px;
}
ul.vehicleinfo li * {
display: block;
}
ul.vehicleinfo li h3 {
font-size: 1.2em;
font-weight: 700;
}
div.autocontent {
width: 760px;
margin-left: 70px;
display: flex;
background: #f3f3f3;
border-radius: 10px;
overflow: hidden;
padding: 10px;
margin-bottom: 10px;
}
.price {
font-weight: 700;
}
.contentbox1 {
column-span: 2;
}
.autoimg img {
width: 340px;
border-radius: 8px;
}
.descript1 {
font-size: 14px;
float: left;
}
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<div class="autocontent">
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg"></div>
</div>
<ul class="vehicleinfo">
<li>
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
</li>
<li>
<h3 class="price">£22,500</h3>
</li>
<div class="descript1">white, 20,000 miles</div>
</ul>
</div>
<div class="autocontent">
<div class="contentbox1">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
</div>
<ul class="vehicleinfo">
<li>
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
</li>
<li>
<h3 class="price">£36,500</h3>
</li>
<div class="descript1">gold, 24,000 miles</div>
</ul>
</div>
Enjoy!
First, there are many things that can be improved in your code and I'll try to explain a bit but I won't change you code too much so you can understand:
with * you target all the elements so putting a width: 890px it's not a good default, if you want to hard reset the browser default. This is the reason your text gets cut off, you can try:
* {
margin: 0;
padding: 0;
}
use the .content div better, you can style it to align all your autocontent, so a small width doesn't do anything good if his children are larger. To get the content aligned with the header text, we can use the same padding or at least the padding-left:
div.content {
width: 800px;
padding: 2em 5em 4em;
}
use display: flex to align the elements BUT don't overuse it. Too many properties will make your code too complex, if you need some examples just check this reference: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
SIMPLIFY the code as much as you can, it will be easier to understand and debug.
Take a look in the FINAL example:
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 16px;
color: #333;
}
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
div.content {
width: 800px;
padding: 2em 5em 4em;
}
.autocontent {
border-top: 1px solid #ddd;
padding: 0 1rem;
margin-bottom: 1rem;
}
ul.vehicleinfo {
display: flex;
justify-content: space-between;
list-style: none;
}
ul.vehicleinfo li {
padding: 1rem 0;
}
.price {
text-align: right;
}
.contentbox {
display: flex;
gap: 1rem;
}
.autoimg img {
width: 320px;
}
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<div class="autocontent">
<ul class="vehicleinfo">
<li>
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
</li>
<li>
<h3 class="price">£22,500</h3>
</li>
</ul>
<div class="contentbox">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg"></div>
<div class="description">white, 20,000 miles</div>
</div>
</div>
<div class="autocontent">
<ul class="vehicleinfo">
<li>
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
</li>
<li>
<h3 class="price">£36,500</h3>
</li>
</ul>
<div class="contentbox">
<div class="autoimg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg"></div>
<div class="description">gold, 24,000 miles</div>
</div>
</div>
Mainly, You're using <ul> and <li> items in the wrong way. UL tag represents a list, and description of an item isn't a list. UL tag should be used wrapping all vehicles and a vehicle should be list item. Other things are:
Invalid html body/head tags
No need for defining the same defining font-family in each html element separately
Code is messy and a lot of CSS properties are use for no reason
Try to avoid fixed widths/heights
I removed a lot of your code and tried to prepare a good starting point for you to continue working on whatever you want to build here.
body {
font-family: sans-serif !important;
}
a {
text-decoration: none;
}
header {
margin: 0;
padding: 2em 5em 4em;
color: #efefef;
overflow: hidden;
position: relative;
}
header::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: skewY(-3deg);
background: red;
transform-origin: bottom left;
z-index: -1;
}
.content {
font-size: 16px;
padding: 50px 0;
}
.vehicle-list {
list-style: none;
margin: 0;
padding: 0;
}
.vehicle {
margin-bottom: 70px;
}
.vehicle__title {
display: flex;
justify-content: space-between;
background-color: yellow;
padding: 10px;
margin-bottom: 16px;
}
.vehicle__title h3 {
font-size: 1.2em;
max-width: 500px;
}
.vehicle__price {
text-align: right;
}
.vehicle__info {
display: flex;
}
.vehicle__description {
font-size: 14px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Used vans for sale - Van Centre | No.1 in the Midlands</title>
</head>
<body>
<header>
<h1>VAN CENTRE</h1>
<h2>1 Anytown Road, Birmingham</h2>
<h3>0121 496 0000</h3>
</header>
<div class="content">
<ul class="vehicle-list">
<li class="vehicle">
<div class="vehicle__title">
<h3>2019 VAUXHALL VIVARO 1.6 TURBO D</h3>
<h3 class="vehicle__price">£22,500</h3>
</div>
<div class="vehicle__info">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg/1024px-2019_Vauxhall_Vivaro_2700_Edition_1.5_Front.jpg" class="vehicle__img" width="340px" />
<div class="vehicle__description">white, 20,000 miles</div>
</div>
</li>
<li class="vehicle">
<div class="vehicle__title">
<h3>2019 FORD TRANSIT CONVERSIONS 2.0 ECOBLUE 170 17 SEAT MINIBUS</h3>
<h3 class="vehicle__price">£36,500</h3>
</div>
<div class="vehicle__info">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/2015_Ford_Transit_460_Trend_2.2.jpg/1024px-2015_Ford_Transit_460_Trend_2.2.jpg" class="vehicle__img" width="340px" />
<div class="vehicle__description">gold, 24,000 miles</div>
</div>
</li>
</ul>
</div>
</body>
</html>
I'm making this site and working on second page. However, I have trouble for centering component in the whole viewport. I searched lots of solutions including position, display:table, etc. But, I couldn't know how to use for this situation.
.header {
background-color: #F7F7F7;
padding: 15px;
}
.header h1 {
float: left;
}
.header h1 img {
display: block;
}
.header__nav {
float: right;
}
.header__nav li {
float: left;
display: flex;
align-items: center;
height: 38px;
}
.header__nav li a {
margin-right: 39px;
display: inline-block;
font-size: 20px;
font-weight: bold;
transition: all 0.5s;
}
.header__nav li a::after {
content: '';
width: 0;
height: 2px;
background-color: black;
transition: 0.3s;
display: block;
}
.header__nav li a:hover::after {
width: 100%;
}
.header__nav li button:hover::before {
width: 100%;
}
.contents {
padding: 150px 100px;
}
.contents__inside {
font-family: 'Playfair Display', serif;
text-align: center;
font-size: 1rem;
}
.contents__inside strong {
font-style: italic;
font-size: 1rem;
}
.contents__inside h2 {
margin-bottom: 10px;
font-size: 6rem;
font-weight: bold;
line-height: 1;
}
.contents__inside img {
width: 100%;
}
.contents__inside p {
max-width: 860px;
font-size: 1.7rem;
font-weight: 400;
margin: 0 auto;
}
.info__inside {
font-family: 'Playfair Display', serif;
text-align: center;
font-size: 1rem;
}
.info__inside h2 {
margin-bottom: 30px;
font-size: 4rem;
font-weight: bold;
line-height: 1;
}
.info__inside p {
max-width: 860px;
font-size: 1.7rem;
font-weight: 400;
margin: 0 auto 100px;
}
.info__inside img {
width: 100%;
}
.footer {
background-color: blue;
}
<header class="header clearfix">
<div class="l-wrapper">
<h1><img src="https://pixelicons.com/wp-content/themes/pexelicons/assets/pic/site-logo/logo.png" alt="Logo"></h1>
<nav class="header__nav">
<ul class="clearfix">
<li>View icons</li>
<li>Buy now</li>
<li><button class="menu">menu</button></li>
</ul>
</nav>
</div>
</header>
<section class="contents">
<div class="l-main">
<div class="contents__inside">
<strong>Top quality</strong>
<h2>ICONS</h2>
<p>6,500 unique icons in different categories.
Drawn by hand and designed for perfection.</p>
<img src="https://pixelicons.com/wp-content/uploads/2018/01/Home_slide_space.png" alt="">
</div>
</div>
</section>
<section class="info">
<div class="l-main">
<div class="info__inside">
<h2>Thousands of icons</h2>
<p>6,500 unique icons in 3 style color, line and solid.</p>
<img src="https://pixelicons.com/wp-content/uploads/2018/01/Preview_rd_2.png" alt="">
</div>
</div>
</section>
<footer class="footer">
</footer>
Is there an any proper method to solve this issue? How can I implement like original design of website?
EDIT
I don't wanna solve by using CSS3 property to practice CSS2
IMAGE that I wanna fix
If i understand you, You want to center your items in your div
To do that you can
.yourDivClassName{
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items:center;
justify-content: center;
}
<body>
<div class="yourDivClassName">
<button>example button</button>
<p>example text</p>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRFU7U2h0umyF0P6E_yhTX45sGgPEQAbGaJ4g&usqp=CAU" alt="example image">
</div>
</body>
I created an inline grid layout for a navigation bar consisting of two columns: logo and nav links. The links are still not inline with the logo. Also, I'm trying to text-transform the link text to be capitalized, but not getting desired result.
Tried modifying the grid and used different padding, but doesn't seem to the correct approach.
body {
font-family: 'Robo', sans-serif;
}
.navbar {
display: inline-grid;
grid-template: auto auto;
grid-column-gap: 680px;
text-decoration: none;
border-bottom: 1px solid rgb(196, 196, 196);
background-color: #F7F9F9;
padding: 10px;
width: 100%;
}
.logo {
grid-column: 1/2;
}
.links {
grid-column: 2/2;
}
.logo h1 {
font-size: 32px;
font-weight: 340;
}
.links a {
text-transform: capitalize;
text-decoration: none;
font-size: 20px;
padding-left: 40px;
}
<nav>
<div class="navbar">
<div class="logo">
<h1>Rick Wilson</h1>
</div>
<div class="links">
Experience
Projects
Technology Stack
Contact
</div>
</div>
</nav>
Also, I'm trying to text-transform the link text to be capitalized,
but not getting desired result.
What is the desired result? Do you maybe want uppercase?
Made some adjustments to your grid layout, is this what you need?
body {
font-family: "Robo", sans-serif;
margin: 0;
}
.navbar {
display: grid;
grid-template-columns: auto 1fr;
border-bottom: 1px solid rgb(196, 196, 196);
background-color: #f7f9f9;
padding: 20px;
align-items: center;
}
.logo {
font-size: 24px;
font-weight: 300;
}
.links {
text-align: right;
}
.links a {
text-transform: capitalize;
text-decoration: none;
font-size: 16px;
margin-left: 20px;
}
<div class="navbar">
<h1 class="logo">Rick Wilson</h1>
<div class="links">
Experience
Projects
Technology Stack
Contact
</div>
</div>
I added display: flex and align-items: center to .links
body {
font-family: 'Robo', sans-serif;
}
.navbar{
display:inline-grid;
grid-template: auto auto;
grid-column-gap: 680px;
text-decoration: none;
border-bottom: 1px solid rgb(196, 196, 196);
background-color:#F7F9F9;
padding:10px;
width: 100%;
}
.logo {
grid-column: 1/2;
}
.links {
grid-column: 2/2;
display: flex;
align-items: center;
}
.logo h1 {
font-size:32px;
font-weight: 340;
}
.links a {
text-transform: capitalize;
text-decoration: none;
font-size:20px;
padding-left: 40px;
}
<header>
<nav>
<div class = "navbar">
<div class = "logo"><h1>Rick Wilson</h1></div>
<div class = "links">
Experience
Projects
Technology Stack
Contact
</div>
</div>
</nav>
</header>
add
display:flex
align-items: center
justify-content: space-between
to .navbar so that both of the flex children .links and .logo will be centered horizontally. Then the justify-content: space-between should push each item out to the left and right sides with space in between them.
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>
If you look at the demo in fullscreen, I'm trying to align all of the inner contents of each div - e.g. You'll notice that the middle cyan div’s contents are not aligned equally with the first and third cyan divs’ contents.
It's difficult to explain, but look at the position of the icon in the middle cyan div compared to the others. If there's a different amount of text inside of each div, how can I make it so that the inner contents are all aligned vertically with the other cyan divs?
.sections {
background: #f2f2f2;
width: 100%;
height: auto;
text-align: center;
padding: 100px 10%;
box-sizing: border-box;
}
#foster-cta-wrap {
background: yellow;
display: flex;
justify-content: space-evenly;
flex-direction: row;
align-items: center;
flex-flow: row wrap;
}
.foster-cta {
box-sizing: border-box;
width: 250px;min-width: 250px;
height: 200px;
background: cyan;
border: 1px solid grey;
margin-top: 30px;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
display: inline-flex;
}
.foster-top {
display: block;
font-size: 30px;
}
.foster-middle {
display: block;
text-transform: uppercase;
font-size: 22px;
font-weight: 400;
}
.foster-bottom {
display: block;
font-weight: 300;
font-size: 16px;
}
.foster-cta:hover {
background: lightgreen;
cursor: pointer;
}
.foster-top a:link, .foster-top a:visited, .foster-middle a:link, .foster-middle a:visited, .foster-bottom a:link, .foster-bottom a:visited {
text-decoration: none;
color: #333;
}
<section class="sections">
<article id="foster-cta-wrap">
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">search engine optimisation</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav><!--
--><nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">SEO</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav><!--
--><nav onclick="location.href='#';" class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">search engine optimisation</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
</article>
</section>
.sections {
background: #f2f2f2;
width: 100%;
height: auto;
text-align: center;
padding: 100px 10%;
box-sizing: border-box;
}
#foster-cta-wrap {
background: yellow;
display: flex;
justify-content: space-evenly;
flex-direction: row;
align-items: center;
flex-flow: row wrap;
}
.foster-cta {
box-sizing: border-box;
width: 250px;min-width: 250px;
height: 200px;
background: cyan;
border: 1px solid grey;
margin-top: 30px;
text-align: center;
}
.foster-top {
display: block;
font-size: 30px;
padding: .5em;
}
.foster-middle {
display: block;
text-transform: uppercase;
font-size: 22px;
font-weight: 400;
}
.foster-bottom {
display: block;
font-weight: 300;
font-size: 16px;
}
.foster-cta:hover {
background: lightgreen;
cursor: pointer;
}
.foster-top a:link, .foster-top a:visited, .foster-middle a:link, .foster-middle a:visited, .foster-bottom a:link, .foster-bottom a:visited {
text-decoration: none;
color: #333;
}
<section class="sections">
<article id="foster-cta-wrap">
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">search engine optimisation</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">SEO</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
<nav onclick="location.href='#';" class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle">search engine optimisation</span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
</article>
</section>
This is what I would do: I removed all the flex formatting on .foster-cta and replaced it with text-align: center;. Then, I added padding to .foster-top to make it look nicer and not contact the other text. The caption is now pushed up against the main title, but this can be fixed by setting padding / margin values for either of them.