Display Background Color for The Page & Align Texts at Center

How to align background color and text in center screen

I add div with class: header, then put all the HTML there and set it to flex, that it will be in the center (justify-content: center, align-items: center, and flex-flow: column because the default is row.)

.header{
display:flex;
justify-content:center;
align-items:center;
flex-flow:column;

.header h1, h2 {
width:500px;
text-align: center;
}

.header h1 {
background-color: goldenrod;
margin: 5px;
}
.header h2 {
margin: 5px;
color: goldenrod;
background-color: black;
}

.content-table {
font-family: Helvetica;
border-collapse:collapse;
font-size: 0.9em;
min-width: 400px;
border-radius: 5px 5px 5px 5px;
overflow: hidden;
box-shadow: -5px 5px 14px black;
margin: auto;
}

.content-table thead tr {
background-color: goldenrod;
font-size: 1.5em;
color: black;
text-align: left;
font-weight: bold;
}
        <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Table Reference Cheat Sheet</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="header">
<h1>HTML Table Reference</h1>
<h2>Table Tags</h2>

<table class="content-table">
<thead>
<tr>
<th>Tag</th>
<th>Name</th>
<th>Description</th>
</tr>

</thead>

<tbody>
<tr>
<td><span class="code"><table></span></td>
<td>Table</td>
<td>The wrapper element for all HTML tables.</td>
</tr>

<tr>
<td><span class="code"><head></span></td>
<td>Table Head</td>
<td>The set of rows defining the column headers in a table.</td>
</tr>

<tr>
<td><span class="code"><body></span></td>
<td>Table Body</td>
<td>The set of rows containing actual table data.</td>
</tr>

<tr>
<td><span class="code"><tr></span></td>
<td>Table Row</td>
<td>The table row container.</td>
</tr>

<tr>
<td><span class="code"><td></span></td>
<td>Table Data</td>
<td>The table data container.</td>
</tr>

<tr>
<td><span class="code"><foot></span></td>
<td>Table Foot</td>
<td>The set of rows defining the footer in a table.</td>
</tr>
</tbody>

</table>

</div>

</body>
</html>

css text align center and background color

Have a look at this:

HTML:

<div>
<span>
my text
</span>
</div>

CSS:

div {
background: red;
text-align: center;
}

span {
background: lime;
}

Live example: JsFiddle

display background color for the page & align texts at center

Replace this style and check it

        .career-page-box{
width: 90%;
margin: auto;
background: #fff;
}
.career-page-box .page-title {
margin: 10px 0 0px 0;
padding: 0;
clear: both;
}
.career-page-box .page-title h1 {
margin: 0;
padding: 0 0 8px 0;
text-align:center;
}
.career-page-box .fill-out {
border-bottom: #ddd solid 1px;
padding: 0 0 10px 0;
margin: 0px 0 10px 0;
text-align: center;
}
.career-page-box .form-panel {
padding: 0;
text-align:center;
}
.career-page-box .form-panel .required {
margin: 10px 0 8px;
}
.career-page-box .form-panel .form-group {
clear: both;
width: 49.8%;
margin:auto;
text-align:left;
}
.career-page-box .form-panel .form-group label{
text-align:left !important;
}
.career-page-box .form-panel .form-group .form-list li {
float: left;
width: 100%;
}
.career-page-box .form-panel .form-group .form-list li label {
line-height: 30px;
padding-right: 30px;
}
.career-page-box .form-panel .form-group .form-list li label em {
color: #df280a;
margin: 0 0 0 2px;
font-style: normal;
}
.career-page-box .form-panel .form-group .custom-select {
float: left;
width: 100%;
margin: 0 0px 0 0;
background-position: 98% 50%;
}
.career-page-box .form-panel .form-group .custom-select select {
margin-top: 0;
}
.career-page-box .form-panel .buttons-set {
clear:both;
border-top: 0;
}
.career-page-box .form-panel .buttons-set button.button {

}

.custom-select {
border: 1px solid #ccc!important;
width: 120px;
height: 30px;
overflow: hidden;
background: #fff url("../images/custom-select-downarrow.png") no-repeat 95% 50%;
}
.arrow-up {
background: transparent url("../images/arrow-up-white.png") no-repeat scroll 0 0;
height: 15px;
width: 25px;
position: absolute;
right: 25px;
top: -15px;
}
.custom-select select {
padding: 5px 8px!important;
width: 100%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
input[type=email],
input[type=search],
input[type=number],
input[type=password],
input[type=tel],
input[type=text] {
width: 100%;
max-width: 100%;
}
input[type=email],
input[type=search],
input[type=number],
input[type=password],
input[type=tel],
input[type=text] {
height: 32px;
padding: 0 8px;
border: 1px solid #d1d1d1;
background: #FFFFFF;
font-size: 13px;
}
.careercv
{
padding-top: 10px;
}
    <div class="career-page-box">
<div class="page-title career-title">
<h1><?php echo $this->__('Career') ?></h1>
</div>
<?php $careerForm=Mage::getSingleton('core/session')->getFormData();?>
<form action="<?php echo mage::getUrl('career/index/save'); ?>" id="carrer_form" method="post" name="carrer_form" enctype='multipart/form-data'>
<div class="fill-out"></div>
<div class="form-panel">
<div class="inner-panel">
<p class="required"><?php echo $this->__('Required Fields') ?><em>*</em></p>
<div class="form-group">
<ul class="form-list">
<li>
<label for="jobtitle"><?php echo $this->__('How did you hear about us') ?><em>*</em></label>
<div class="custom-select">
<select name="jobtitle" id="jobtitle" class="validate-select form-control required-entry">
<option value="">Please Select</option>
<option value="NewsPaper" <?php if($careerForm['jobtitle']=="NewsPaper"){
?>selected="selected"<?php } ?>>NewsPaper</option>
<option value="onlinsite" <?php if($careerForm['jobtitle']=="onlinsite"){?>selected="selected"<?php } ?>>Online Website</option>
<option value="Friends" <?php if($careerForm['jobtitle']=="Friends"){?>selected="selected"<?php } ?>>Friends</option>
</select>
</div>
</li>
<li>
<label for="jobtitle"><?php echo $this->__('Job Type') ?><em>*</em></label>
<?php $jobs=Mage::getStoreConfig('career/career/job_list');
if($jobs!='')
$jobsselected=explode(",",$jobs);
else
$jobsselected='';

?>
<div class="custom-select">
<select name="job" id="job" class="form-control required-entry">
<option value=""> Please Select </option>
<?php foreach($jobsselected as $jobs): ?>
<option value="<?php echo $jobs ?>"> <?php echo $jobs; ?> </option>
<?php endforeach; ?>
</select>
</div>
</li>
</ul>
</div>
<div class="form-group">
<ul class="form-list">
<li>
<label for="firstname"><?php echo $this->__('First Name') ?><em>*</em></label>
<input name="fname" class="form-control required-entry" size="45" type="text" placeholder="<?php echo $this->__('') ?>" value="<?php echo $careerForm['fname'];?>"/>
</li>
<li>
<label for="lastname"><?php echo $this->__('Last Name') ?><em>*</em></label>
<input name="lname" class="form-control required-entry" size="45" type="text" placeholder="<?php echo $this->__('') ?>" value="<?php echo $careerForm['lname'];?>"/>
</li>
</ul>
</div>
<div class="form-group">
<ul class="form-list">
<li>
<label for="emailaddress"><?php echo $this->__('Email address') ?><em>*</em></label>
<input name="email_address" placeholder="<?php echo $this->__('') ?>" class="form-control required-entry validate-email" type="text" value="<?php echo $careerForm['email_address'];?>"/>
</li>
</ul>
</div>
<div class="form-group">
<ul class="form-list">
<li>
<label for="telephonenumber"><?php echo $this->__('Telephone Number') ?><em>*</em></label>
<input name="phone" class="form-control required-entry validate-number" type="text" value="<?php echo $careerForm['phone'];?>" />
</li>
</ul>
</div>
<div class="form-group">
<ul class="form-list">
<li>
<label for="cv"><?php echo $this->__('Upload Your Cv') ?><em>*</em></label>
<input name="cv" class="form-control required-file careercv" type="file" />
</li>
</ul>
</div>
<div class="buttons-set">
<button class="button" title="<?php echo $this->__('Submit Your Cv'); ?>" type="submit"><span><span><?php echo $this->__('Submit Cv') ?></span></span></button>
</div>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var carrerForm = new VarienForm('carrer_form', true);
//]]>
</script>
</div>

Center text correctly in background color

Put the styles to the DIV itself, not only to its hovered state:

const style={
display: flex;
align-items:center;
cursor: "pointer",
height:"30px"
};

Apply background color to the width of the text and center it

Try the below code (using flexbox):

.order {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}

.order h3 {
font-family: Raleway;
color: white;
background-color: blue;
}

.order h1 {
font-family: Raleway;
background-color: blue;
}
<div class="order">
<h3>Hello world</h3>
<h1>How are you doing</h1>
</div>

Vertically center-align col text with background color in bootstrap 4.1

Try this:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet"/><div class="row">  <div class="col-md-3 d-flex justify-content-center align-items-center" style="background-color: #4a90e2;">      Align  </div>  <div class="col-md-9">    <div class="p-2 bd-highlight">Flex item 1</div>    <div class="p-2 bd-highlight">Flex item 2</div>    <div class="p-2 bd-highlight">Flex item 3</div>    <button type="button" class="btn btn-primary">Primary</button>  </div></div>


Related Topics



Leave a reply



Submit