Trouble centering CSS columns - css

I have a three column box in css, I need it to center on the page for the desktop and then stack the columns on top of each other in 600px or less. I have everything working except having it centered on the desktop view.
I have tried adding justify-content: relative, adding a wrapper align: center and a couple other lines of code that did not work. Any help is greatly appreciated.
Here is the code I currently have:
* {
box-sizing: border-box;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 178px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
<p align="center">
<font size="5" color="336699"><strong>Great American Song Contest</strong></font>
</p>
<p align="center">
<font size="3" color="a91e21"><strong>3 Easy Ways To Enter Your Songs</strong></font>
</p>
<div class="wrapper">
<div class="row">
<div class="column">
<p>
<a href="https://www.greatamericansong.com/newsite-backup/Form-Prepage.php/"><img src="https://www.greatamericansong.com/newsite-backup/images/submit-online.gif" alt="" width="178" height="158"></p>
</div>
<div class="column">
<p>
<a href="https://www.greatamericansong.com/newsite-backup/Entry-Direct.php/"><img src="https://www.greatamericansong.com/newsite-backup/images/submit-email.gif" alt="" width="178" height="158"></p>
</div>
<div class="column">
<p>
<img src="https://www.greatamericansong.com/newsite-backup/images/submit-mail.gif" alt="" width="178" height="158">
</p>
</div>
</div>
</div>
<div align="center"> <img src="//shield.sitelock.com/shield/greatamericansong.com" id="sl_shield_image" style="cursor: pointer;" alt="SiteLock" align="middle" />
<script id="sl_shield" type="text/javascript" src="//shield.sitelock.com/sitelock.js" language="javascript"></script>
</div>
<p align="center">
<p></p>
<p align="center"><strong>* WRITERS RETAIN ALL RIGHTS TO THEIR SONGS, LYRICS & COMPOSITIONS *</strong></p>
<p>
<font size="3" color="a91e21"><strong>2021 Rules & Entry:</strong></font>
</p>
<p>The Great American Song Contest is open to songwriters, lyricists & music composers worldwide.</p>
<p align="center"><strong>* WRITERS RETAIN ALL RIGHTS TO THEIR SONGS, LYRICS & COMPOSITIONS *</strong></p>

Apply a dedicated class to the parent of those columns (in my example: class="x"), use display: flex; and justify-content: center on that, and in the media query change it to flex-direction: column (t place them below each other) and align-items: center; (to center them). And forget the floats...
* {
box-sizing: border-box;
}
.column {
width: 178px;
}
.x {
display: flex;
justify-content: center;
}
#media screen and (max-width: 600px) {
.x {
flex-direction: column;
align-items: center;
}
}
<p align="center">
<font size="5" color="336699"><strong>Great American Song Contest</strong></font>
</p>
<p align="center">
<font size="3" color="a91e21"><strong>3 Easy Ways To Enter Your Songs</strong></font>
</p>
<div class="wrapper">
<div class="x">
<div class="column">
<p>
<a href="https://www.greatamericansong.com/newsite-backup/Form-Prepage.php/"><img src="https://www.greatamericansong.com/newsite-backup/images/submit-online.gif" alt="" width="178" height="158"></p>
</div>
<div class="column">
<p>
<a href="https://www.greatamericansong.com/newsite-backup/Entry-Direct.php/"><img src="https://www.greatamericansong.com/newsite-backup/images/submit-email.gif" alt="" width="178" height="158"></p>
</div>
<div class="column">
<p>
<img src="https://www.greatamericansong.com/newsite-backup/images/submit-mail.gif" alt="" width="178" height="158">
</p>
</div>
</div>
</div>
<div align="center"> <img src="//shield.sitelock.com/shield/greatamericansong.com" id="sl_shield_image" style="cursor: pointer;" alt="SiteLock" align="middle" />
<script id="sl_shield" type="text/javascript" src="//shield.sitelock.com/sitelock.js" language="javascript"></script>
</div>
<p align="center">
<p></p>
<p align="center"><strong>* WRITERS RETAIN ALL RIGHTS TO THEIR SONGS, LYRICS & COMPOSITIONS *</strong></p>
<p>
<font size="3" color="a91e21"><strong>2021 Rules & Entry:</strong></font>
</p>
<p>The Great American Song Contest is open to songwriters, lyricists & music composers worldwide.</p>
<p align="center"><strong>* WRITERS RETAIN ALL RIGHTS TO THEIR SONGS, LYRICS & COMPOSITIONS *</strong></p>

Related

Flex-Box height, not equal when scaling page

I have an issue with flexbox, where the 2 flex boxes side by side, do not share an equal height when scaling the page. I'll include a picture below, but one box contains a react-bootstrap carousel, while the other contains text. How do I keep them at the same height so that they will scale on all screen sizes?
Here is the JSX
<div className={styles.floatchild1}>
<Carousel fade className={styles.viewMap}>
<Carousel.Item>
<img
className="d-block w-100"
src="/open.jpeg"
alt="Front View of HICO Storage Unit, Grand Junction Colorado"
/>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block w-100"
src="/inside.jpeg"
alt="Inside of HICO Storage Unit, Grand Junction Colorado"
/>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block w-100"
src="/side-view-container.jpeg"
alt="Side View of HICO Storage Unit, Grand Junction Colorado"
/>
</Carousel.Item>
</Carousel>
<Button
className={styles.viewMapButton}
href="https://www.google.com/maps/place/2487+Commerce+Blvd,+Grand+Junction,+CO+81505/#39.0906152,-108.5944703,17z/data=!3m1!4b1!4m5!3m4!1s0x87471d18f2c3486b:0xe36fb2de2017f121!8m2!3d39.0906111!4d-108.5922816"
target="_blank"
>
+ View Map
</Button>
<div className={styles.buttonIdRow}>
<p></p>
<a>Jump to:</a>
Units
</div>
</div>
<div className={styles.floatchild2}>
<p>
Self Storage in <u>Grand Junction</u>, Co
</p>
<h2 className={styles.hicoLogo}>
<b>
<u>HICO Storage Company</u>
</b>
</h2>
<div className={styles.addressPhone}>
<h3 className={styles.address}>
<div className={styles.pinPicture}>
<Image
src="/pin.png"
alt="location pin"
width={20}
height={28}
/>{" "}
</div>
<div className={styles.location}>
2487 Commerce Blvd, Grand Junction, CO 81505
</div>
</h3>
<h3 className={styles.phoneWrapper}>
<div className={styles.phonePicture}>
<Image
src="/phone.png"
alt="location pin"
width={25}
height={25}
/>{" "}
</div>
<div className={styles.phone}>
<a className={styles.phoneColor} href="tel:8088962272">
<b>808-896-2272</b>
</a>
</div>
</h3>
</div>
<hr />
<div className={styles.hours}>
<div className={styles.officeHours}>
<p className={styles.TimeTitle}>Office Hours</p>
<p className={styles.TimeP}>
8:30am - 5:30pm Monday - Saturday
</p>
<p className={styles.TimeP}>10:30am - 3:30pm Sunday</p>
</div>
<div className={styles.officeHours}>
<p className={styles.TimeTitle}>Gate Hours</p>
<p className={styles.TimeP}>24/7 access</p>
</div>
</div>
<hr />
<Button href='/contact' className={styles.interestedButton}>Interested? Contact Us</Button>
</div>
</div>
And here is the CSS I'm using to style it
.wrapper {
overflow: hidden;
min-width: 300px;
display: flex;
flex-direction: row;
width: 90%;
font-family: 'southern';
align-items: center;
}
.floatchild1{
background: white;
flex:1;
min-width: 380px;
align-items: center;
}
.floatchild2 {
background: white;
flex:1;
min-width: 380px;
align-items: center;
padding: 4%;
}
Just change
align-items: center;
at .wrapper to
align-items: stretch;
Working codepen: https://codepen.io/maty1000/pen/oNEqvGY

css form elements alignment issue

I am creating a form using css and having issues with alignment for certain fields. This layout consists of multiple columns
The issues are as follows
The two checkboxes are appearing next to each other , instead of one below the other
The second column should appear close to the first column, not able to remove the whitespace, should I set the col width for each column ?
the html code seems cumbersome, since each column needs to contain the fields based on the required fields, not sure if I am using correct approach , new to css
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
text-align: center;
}
.container1 {
display: flex;
flex-direction: row;
margin: 10px 50px 10px
}
.container2 {
display: flex;
justify-content: center;
}
.col1 {
flex: 1
}
.col2 {
flex: 1;
align-items: start
}
.button-basic {
border: 1px solid black;
border-radius: 5px;
margin: 10px;
padding: 10px
<body>
<h1> Employee information </h1>
<form>
<div class="container1">
<div class="col1">
<p> Employee id:</p>
<p> Employee Type:</p>
<p> Employee Status: </p>
<p> Promotion Flag:</p>
<p> Insurance Flag:</p>
</div>
<div class="col2">
<p id="employee-id"> 12345 </p>
<p id="employee-type"> HR </p>
<p id="employee-status"> Active </p>
<input type="checkbox" id="promotion-flag" name="promotion-flag">
<input type="checkbox" id="insurance-flag" name="insurance-flag">
</div>
<div class="col1">
<p> Employee First Name: </p>
<p> Description: </p>
<p> Description: </p>
<p> Promotion comments: </p>
</div>
<div class="col2">
<p id="employee-fname"> John </p>
<p id="employee-type-desc"> HR employee </p>
<p id="employee-status-desc"> Active employee </p>
<input type="text" id="promotion-reason" name="promotion-reason">
</div>
<div class="col1">
<p> Employee Last Name: </p>
<p> Employee Start Date: </p>
</div>
<div class="col2">
<p id="employee-lname"> Smith </p>
<p id="employee-start-date"> 01/01/2020 </p>
</div>
</div>
<div class="container2">
<input class="button-basic" type="submit" value="Search">
<input class="button-basic" type="submit" value="Save">
</div>
</form>
you need to give the page a purpose with design
try for getting rid of the spaces
.col1 {
flex: 1;
text-align: right;
}
.col2 {
flex: 1;
text-align: left;
}
also.. learn about the box model for getting the gaps prettier
with the checkboxes you just need to add a <br>
...
<div class="col2">
<p id="employee-id"> 12345 </p>
<p id="employee-type"> HR </p>
<p id="employee-status"> Active </p>
<input type="checkbox" id="promotion-flag" name="promotion-flag"><br>
<input type="checkbox" id="insurance-flag" name="insurance-flag">
</div>
...
consider to use a table instead of wiring a bunch of divs

Convert style and html to gmail capable

I tried many times on sending an html with style email to gmail, but it always destroy the style it expected look like in normal HTML. Anyone could kindly help me to convert it to gmail capable that must look exactly the same it should be? Thank you.
<div style="display: flex;justify-content: center;">
<div class="container" style="font-family: 'Manrope-Regular';max-width: 600px;border-style: solid;border-color: #7E7E7E;position: relative;height: fit-content;border-width: 1px;">
<img class="top-bg" src="https://saas-staging-wp.chatsmart.io/wp-content/uploads/revslider/slider-1/1-Path 842 (1).png" style="max-width: 255px;position: absolute;right: 0;">
<img class="bottom-bg" src="https://saas-staging-wp.chatsmart.io/wp-content/uploads/revslider/slider-1/1-Path 841.png" style="position: absolute;left: 0;bottom: 0;max-width: 270px;">
<div class="logo" style="font-family: 'Manrope-Regular';">
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/08030440/mobile-menu-logo.png" style="margin: 41px auto;display: block;">
</div>
<div class="content" style="font-family: 'Manrope-Regular';margin: 0 100px;">
<p class="header" style="font-family: 'Manrope-Regular';">Hi [first_name] [last_name],</p>
<p class="para" style="font-family: 'Manrope-Regular';">Welcome to ChatSmart! Experience the powerful ChatSmart features to let you easily reach your customers. Not only increase customers loyalty through broadcast messages, but also lower abandon cart rate by supporting eCommerce platforms. Create your sales revenue by 24 / 7 answer customers' enquiries!
</p>
<p class="para" style="font-family: 'Manrope-Regular';">
<strong>Some popular resources which would be useful for you:</strong>
</p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">How to login & connect WhatsApp? (Cantonese)</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">How to start the chat with your customer? (Cantonese)</span></li>
</ul>
<br>
<p class="para" style="font-family: 'Manrope-Regular';">
For more support, you may find below:
</p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">ChatSmart User Guide (Traditional Chinese)</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Technical Support</span></li>
</ul>
<br>
<p class="para" style="font-family: 'Manrope-Regular';">Click below button to start your journey in ChatSmart!</p>
<a class="button button-text" href="[link]" style="justify-content: center;display: flex;">
<img style="max-width: 206px;" src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/21125343/login.png"/>
</a>
<br>
<p class="para" style="font-family: 'Manrope-Regular';">More super practical content is on the way, stay tuned!</p>
<br>
<p class="para" style="font-family: 'Manrope-Regular';">Thanks,</p>
<br>
<p class="signature" style="font-family: 'Manrope-Regular';font-weight: bold;">
ChatSmart Team<br>
Your Best WhatsApp Marketing Platform
</p>
<br>
<div class="soscial" style="font-family: 'Manrope-Regular';">
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/06145810/Group-764.png" style="margin-right: 20px;">
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/06150156/1-Group%20766.png" style="margin-right: 20px;">
</div>
<br>
<div class="footer" style="font-family: 'Manrope-Regular';text-align: center;font-size: 8px;margin-bottom: 20px;">
©2021 ChatSmart, Inc. All rights reserved.
</div>
</div>
</div>
</div>
Updated: Included a version of style and head block.
<html>
<head>
<style>
#font-face {
font-family: 'Manrope-Regular';
src: url('https://saas-staging.chatsmart.io/font/Manrope-Regular.ttf') format("opentype");
}
p, div {
font-family: 'Manrope-Regular';
}
body{
display: flex;
justify-content: center;
}
.container {
max-width: 600px;
border-style: solid;
border-color: #7E7E7E;
position: relative;
height: fit-content;
border-width: 1px;
}
.top-bg {
max-width: 255px;
position: absolute;
right: 0;
}
.bottom-bg {
position: absolute;
left: 0;
bottom: 0;
max-width: 270px;
z-index: -1;
}
.logo img {
margin: 41px auto;
display: block;
}
.content {
margin: 0 100px;
}
a.button {
text-decoration: none;
}
.signature {
font-weight: bold;
}
.soscial img {
margin-right: 20px;
}
.footer {
text-align: center;
font-size: 8px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<img class="top-bg" src="https://saas-staging-wp.chatsmart.io/wp-content/uploads/revslider/slider-1/1-Path 842 (1).png" />
<img class="bottom-bg" src="https://saas-staging-wp.chatsmart.io/wp-content/uploads/revslider/slider-1/1-Path 841.png" />
<div class="logo">
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/08030440/mobile-menu-logo.png" />
</div>
<div class="content">
<p class="header">Hi [first_name] [last_name],</p>
<p class="para">Welcome to ChatSmart! Experience the powerful ChatSmart features to let you easily reach your customers. Not only increase customers loyalty through broadcast messages, but also lower abandon cart rate by supporting eCommerce platforms. Create your sales revenue by 24 / 7 answer customers' enquiries!
</p>
<p class="para">
<strong>Some popular resources which would be useful for you:</strong>
</p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">How to login & connect WhatsApp? (Cantonese)</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">How to start the chat with your customer? (Cantonese)</span></li>
</ul>
<br/>
<p class="para">
For more support, you may find below:
</p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">ChatSmart User Guide (Traditional Chinese)</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Technical Support</span></li>
</ul>
<br/>
<p class="para">Click below button to start your journey in ChatSmart!</p>
<a class="button button-text" href="[link]" style="justify-content: center;display: flex;">
<img style="max-width: 206px;" src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/21125343/login.png"/>
</a>
<br/>
<p class="para">More super practical content is on the way, stay tuned!</p>
<br/>
<p class="para">Thanks,</p>
<br/>
<p class="signature">
ChatSmart Team<br/>
Your Best WhatsApp Marketing Platform
</p>
<br/>
<div class="soscial">
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/06145810/Group-764.png" />
<img src="https://chatsmart-saas.s3.ap-east-1.amazonaws.com/wp/images/2021/01/06150156/1-Group%20766.png" />
</div>
<br/>
<div class="footer">
©2021 ChatSmart, Inc. All rights reserved.
</div>
</div>
</div>
</body>
</html>
You need a complete redesign. You can't develop emails like websites, because there are lots of restrictions. For example, you need to write code inline, not rely on embedded CSS (within <style>...</style>); and things like divs and flexbox are temperamental - see caniemail.com.
Check out any HTML email template, or HTML email course, and then make sure you test in a variety of email clients on a variety of devices.

I need each row to have same height

I need to make divs look like table data, I have used display: table-cell and display: table properties but i didn't get expected layout. I need each row to have same height.
please check below code
.publishers {
margin: 45px 0;
margin-right: 60px;
}
.publishers .col-xs-6:nth-child(odd) .publisher {
margin-right: -10px;
}
.publishers .col-xs-6:nth-child(even) .publisher {
margin-left: -10px;
}
.publishers .publisher {
background-color: #f1efef;
margin-bottom: 10px;
}
.publishers .publisher .media {
padding: 10px;
}
.publishers .publisher .media .media-left img {
width: 128px;
height: 128px;
}
.publishers .publisher .media .media-body h3 {
font-size: 30px;
font-weight: 400;
}
/***** my try *****/
.publishers{
display:table;
}
.publishers .publisher{
display: table-cell;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<section class="publishers">
<div class="row">
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://www.cengage.com
">
<img style=" height: auto;" src="Publishers/7726f4a3-b23d-4af1-879d-57da2a567bd1.jpg" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://www.cengage.com
"><h3>Cengage</h3></a>
<p class="description">A company that delivers highly..
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://www.elsevier.com
">
<img style=" height: auto;" src="Publishers/b3723614-ea79-4b24-a9fb-ae0c1da9a3c4.png" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://www.elsevier.com
"><h3>Elsevier </h3></a>
<p class="description">A world’s leading publisher of science and health information serves more than 30 million scientists, students and health and information professionals worldwide
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="http://eu.wiley.com/WileyCDA/Section/index.html
">
<img style=" height: auto;" src="Publishers/ff9e4261-36a1-4cd3-bf9c-c169ff8661eb.png" alt="...">
</a>
</div>
<div class="media-body">
<a href="http://eu.wiley.com/WileyCDA/Section/index.html
"><h3>WILEY</h3></a>
<p class="description">Wiley is a global publisher of print and electronic products, textbooks, and other educational materials, for students both undergraduate and postgraduate, specializing in scientific, technical, and medical books and journals; professional and consumer books and subscription services. Wiley has approximately 22,700 active titles and 400 journals, and publishes 2000 new titles in a variety of print and electronic formats each year
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="publisher">
<div class="media">
<div class="media-left">
<a style=" height: 131px; display: block;" href="https://www.pearson.com/
">
<img style=" height: auto;" src="Publishers/d18fbae5-1587-4b06-a0e4-8b0b1ec4ab13.jpg" alt="...">
</a>
</div>
<div class="media-body">
<a href="https://www.pearson.com/
"><h3>Pearson</h3></a>
<p class="description">Global leader in educational publishing offers comprehensive range of educational programs, in all subjects, for every age and level of student, from preK-12 through higher education and on into professional life.
</p>
</div>
</div>
</div>
</div>
</div>
</section>
.publishers .row {
display: flex;
}
If you don't need IE9 and below support you can use flex this by default uses align-items: stretch which makes all the children full height
If content is static then u can take height of longest div and assign to all.
If content is dynamic then:
$(document).ready(function() {
var maxHeight = -1;
$('.features').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('.features').each(function() {
$(this).height(maxHeight);
});
});
You could loop through each of the .features, find the max then apply that height to all blocks of the same class.
$(document).ready(function() {
var blockHeights;
blockHeights = [];
$('.features').each(function() {
blockHeights.push($(this).height());
});
$('.features').height(Math.max.apply(Math, blockHeights));
});
If you load your content through ajax or some other method after document ready simply move this into a function and call that when ready.
Probably worth setting a height (or height:auto) on the block as a style incase java script is off or doesn't load correctly, just to ensure the content is always visible.
You were almost there. display:table works. The problem is that your bootstrap is adding float to your divs, which break the table. Add in your css float:none; and it will work. Jsfiddle for example : http://jsfiddle.net/42dy9aLm/

Display image and text in same line

I want to display image and text in one line like tripadvisor.in/
<div style="display:inline-block">
<div style="display:inline;float:left">
<a href="CollegeProfile.php" class="white">
<h4 style="margin-bottom:10px;display:inline">Nice college to study</h4></a>
<br />Read reviews of Indian institute of management,Ahmedabad
</div>
</div>
<div style="display:inline-block">
<img class="shakeImage" src="assets/img/author.jpg" style="border: 1px solid white;height:60px;display:inline" />
</div>
It shows image and text in separate line like:
If you need to stick using div elements, you can do this with the below:
Demo Fiddle
HTML
<div class='table'>
<div class='cell'>
<h4 >Nice college to study</h4>
Read reviews of Indian institute of management,Ahmedabad
</div>
<div class='cell'>
<img class="shakeImage" src="assets/img/author.jpg" style="border: 1px solid white;height:60px;display:inline" />
</div>
</div>
CSS
.table {
display:table;
}
.cell {
display:table-cell;
vertical-align:middle;
}
h4 {
margin:0;
}

Resources