I am facing some alignment issues in one of my websites. Basically it's a responsive issue
I have created a Pure Css Vertical Timeline and beside that timeline there are multiple paragraphs describing what the timeline is about. Now the issue I am facing is that aligning all the paragraphs vertically as same height as the timeline.
Here are codes
SCSS
.col-md-4 {
#media #{$mq9b} {
display: none;
}
#media #{$mq7b} {
display: none;
}
.timeline {
list-style-type: none;
position: relative;
#media #{$mq7b} {
padding-left: 60px;
position: relative;
left: 50%;
margin-left: -86px;
}
&:before {
content: ' ';
background: $timeline_color;
display: inline-block;
position: absolute;
left: 29px;
width: 3px;
height: 100%;
z-index: 400;
#media #{$mq7b} {
position: absolute;
left: 48px;
}
}
li {
margin: 90px 0;
padding-left: 20px;
position: relative;
#media #{$tablet} {
line-height: 34px;
}
&:before {
content: ' ';
background: $timeline_color;
display: inline-block;
position: absolute;
border-radius: 50%;
left: -36px;
width: 50px;
height: 50px;
z-index: 400;
}
a {
margin-left: 20px;
color: $black;
font: 20px $lato;
position: relative;
top: 8px;
}
i {
position: absolute;
top: 12px;
left: -22px;
z-index: 1000;
color: $black;
font-size: 24px;
}
}
}
}
.col-md-8 {
.paragraph_wrapper {
.timeline_paragraphs {
list-style-type: none;
.only_mobile_disp {
display: none;
h6 {
display: none;
#media #{$mq9b} {
display: block;
font-size: 30px;
text-align: center;
border-bottom: 1px solid #dedede;
padding-bottom: 10px
}
#media #{$mq7b} {
display: block;
font-size: 20px;
text-align: center;
border-bottom: 1px solid #dedede;
padding-bottom: 10px
}
.disp_mobile {
opacity: 0;
#media #{$mq9b} {
opacity: 1;
padding-right: 20px;
position: relative;
font-size: 16px;
padding-top: 10px;
}
#media #{$mq7b} {
// opacity: 1;
padding-right: 20px;
position: relative;
font-size: 16px;
padding-top: 10px;
}
&:before {
position: relative;
z-index: 1;
}
&:after {
position: absolute;
top: 4px;
left: 50%;
width: 30px;
height: 30px;
background-color: $timeline_color;
content: "";
margin-left: -25px;
#include border-radius(50%);
}
}
}
}
li {
margin: 90px 0;
}
}
}
}
HTML
<div class="col-md-4 col-sm-6 wow fadeInLeft" data-wow-delay="0.1s">
<ul class="timeline">
<li> 2019 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2018 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2016 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2014 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2012 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2010 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 2002 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 1992 <i class="fa fa-calendar" aria-hidden="true"></i></li>
<li> 1973 <i class="fa fa-calendar" aria-hidden="true"></i></li>
</ul>
</div>
<div class="col-md-8 col-sm-12 col-xs-12 wow fadeInRight" data-wow-delay="0.2s">
<div class="paragraph_wrapper">
<ul class="timeline_paragraphs">
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2019</h6>
</li>
<li>
Handed Over BANERGATTA CENTRAL, A Part of PRIMCO SPECTRUM.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2018</h6>
</li>
<li>
The Pavilion Residential Project Handed Over, Union City a mixed Development project launched.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2016</h6>
</li>
<li>
1.3 million sft of Workspace, Retail AND Hospitality ongoing and projected to complete Q1 2017. Handover of ‘FIESTA HOMES’ and 5 Ongoing Projects.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2014</h6>
</li>
<li>
2 million stf of new commercial & retail projects completed.Handover of ' watermark ' & ' crystal cove ' commenced.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2012</h6>
</li>
<li>
3 commercial projects completed. 5 residential projects launched.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2010</h6>
</li>
<li>
SJR Primecorp is incorporated.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>2002</h6>
</li>
<li>
Commercial, Residential development begins under the new SJR identity.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>1992</h6>
</li>
<li>
First Commercial Project. SJR Towers for Infosys.
</li>
<li class="only_mobile_disp">
<h6><i class="fa fa-calendar disp_mobile" aria-hidden="true"></i>1973</h6>
</li>
<li>
Founded by S Jayarama reddy. Begins with Infrastructure ‐ Airport Tarmacs, Flyover, Higways and Factories.
</li>
</ul>
</div>
</div>
Related
This is the website I'm currently have to work with: https://www.mpc.gov.my/home. Everything seems fine when you view using a desktop or big screen, but when you try to browse it using a mobile/smaller screen the navigation menu is giving the user a headache.
How can I fix it? I don't want the menu to disappear if I scroll down. Anyone get any ideas?
$(document).ready(function() {
"use strict";
$('.menu > ul > li:has( > ul)').addClass('menu-dropdown-icon');
$('.menu > ul > li > ul:not(:has(ul))').addClass('normal-sub');
$(".menu > ul").before(" ");
$(".menu > ul > li").hover(function(e) {
if ($(window).width() > 943) {
$(this).children("ul").stop(true, false).fadeToggle(150);
e.preventDefault();
}
});
$(".menu > ul > li").click(function() {
if ($(window).width() <= 943) {
$(this).children("ul").fadeToggle(150);
}
});
$(".menu-mobile").click(function(e) {
$(".menu > ul").toggleClass('show-on-mobile');
e.preventDefault();
});
});
$(window).resize(function() {
$(".menu > ul > li").children("ul").hide();
$(".menu > ul").removeClass('show-on-mobile');
});
/*===================================
Third Mega Menu
=====================================*/
.menu {
width: 100%;
}
.menu-container {
margin: 0 auto;
background: #e9e9e9;
}
.menu a.logo {
display: inline-block;
padding: 1.5em 3em;
width: 19%;
float: left;
}
.menu img {
max-width: 100%;
}
.menu-mobile {
display: none;
padding: 20px;
}
.menu-mobile:after {
content: "\f0c9";
font-family: "Font Awesome 5 Pro";
font-size: 2.5rem;
padding: 0;
float: right;
position: relative;
top: 50%;
-webkit-transform: translateY(-25%);
transform: translateY(-25%);
}
.menu-dropdown-icon:before {
content: "\f0c9";
font-family: "Font Awesome 5 Pro";
display: none;
cursor: pointer;
float: right;
padding: 1.5em 2em;
background: #fff;
color: #333;
}
.menu>ul {
margin: 0 auto;
width: 100%;
list-style: none;
padding: 0;
position: relative;
/* IF .menu position=relative -> ul = container width, ELSE ul = 100% width */
box-sizing: border-box;
clear: right;
}
.menu>ul:before,
.menu>ul:after {
content: "";
display: table;
}
.menu>ul:after {
clear: both;
}
.menu>ul>li {
float: left;
background: #e9e9e9;
padding: 0;
width: 25%;
/* added- aidan */
margin: 0;
list-style: none!important;
}
.menu>ul>li a {
text-decoration: none;
padding: 1.5em 3em;
display: block;
}
.menu>ul>li:hover {
background: #f0f0f0;
}
.menu>ul>li>ul {
display: none;
width: 100%;
background: #f0f0f0;
padding: 20px;
position: absolute;
z-index: 99;
left: 0;
margin: 0;
list-style: none;
box-sizing: border-box;
}
.menu>ul>li>ul:before,
.menu>ul>li>ul:after {
content: "";
display: table;
}
.menu>ul>li>ul:after {
clear: both;
}
.menu>ul>li>ul>li {
margin: 0;
padding-bottom: 0;
list-style: none;
width: 25%;
background: none;
float: left;
list-style: none!important;
/* added - aidan */
}
.menu>ul>li>ul>li a {
color: #777;
padding: .2em 0;
width: 95%;
display: block;
border-bottom: 1px solid #ccc;
}
.menu>ul>li>ul>li a:hover {
color: #03a9f4;
}
.menu>ul>li>ul>li>ul {
display: block;
padding: 0;
margin: 10px 0 0;
list-style: none;
box-sizing: border-box;
margin-left: 20px;
text-indent: -10px;
}
.menu>ul>li>ul>li>ul:before,
.menu>ul>li>ul>li>ul:after {
content: "";
display: table;
}
.menu>ul>li>ul>li>ul:after {
clear: both;
}
.menu>ul>li>ul>li>ul>li {
float: left;
width: 100%;
padding: 0px 0;
/*reduced to 0px - aidan */
list-style: none!important;
/*added -aidan */
margin: 0!important;
/*added !important - aidan*/
font-size: .8em;
}
.menu>ul>li>ul>li>ul>li a {
border: 0;
font-size: 14px;
}
.menu>ul>li>ul.normal-sub {
width: 300px;
left: auto;
padding: 10px 20px;
}
.menu>ul>li>ul.normal-sub>li {
width: 100%;
}
.menu>ul>li>ul.normal-sub>li a {
border: 0;
padding: 1em 0;
}
.head-sub {
font-weight: 700;
/* added - aidan */
color: #be1621!important;
/* added - aidan */
}
.mobile-vue {
display: none!important;
}
.desktop-vue {
display: block!important;
padding: 0px!important;
}
li.menu-dropdown-icon {
margin: 0px!important;
}
.img-desktop-vue {
max-width: 70%!important;
}
.tertiary-menu {
background-color: #e3e3e3;
/* added - aidan */
}
/* ––––––––––––––––––––––––––––––––––––––––––––––––––
Mobile style's
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#media only screen and (max-width: 991px) {
.mobile-vue {
display: block!important;
/*added - aidan*/
}
.desktop-vue {
display: none!important;
/*added - aidan*/
padding: unset;
}
li.menu-dropdown-icon {
margin: unset!important;
/*added - aidan*/
}
.menu-container {
width: 100%;
display: block;
}
.menu-container .menu {
display: inline-block;
}
.menu-mobile {
display: block;
float: right;
padding: 20px 20px 0;
}
.menu-dropdown-icon:before {
display: block;
}
.menu>ul {
display: none;
width: 100%;
}
.menu>ul>li {
width: 100%;
float: none;
display: block;
margin: 0!important;
/* added - aidan */
}
.menu>ul>li a {
padding: 1.5em;
width: 100%;
display: block;
color: #000000;
}
.menu>ul>li>ul {
position: relative;
padding: 0 40px;
}
.menu>ul>li>ul.normal-sub {
width: 100%;
}
.menu>ul>li>ul>li {
float: none;
width: 100%;
margin-top: 20px;
margin: 0!important;
/* added - aidan*/
}
.menu>ul>li>ul>li a {
width: 90%;
/* added - aidan */
}
.menu>ul>li>ul>li:first-child {
margin: 0;
}
.menu>ul>li>ul>li>ul {
position: relative;
}
.menu>ul>li>ul>li>ul>li {
float: none;
}
.menu .show-on-mobile {
display: block;
}
.container-mobil {
padding-left: unset!important;
padding-right: unset!important;
}
}
.fas,
.far {
padding-right: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="menu-container">
<div class="menu">
<ul class="clearfix">
<li>
<img src="/static_files/media_manager/1/Index-About-EN-1.png" class="img-desktop-vue">
ABOUT MPC
<ul>
<li>Corporate Info
<ul>
<li><i class="fas fa-building"></i> Background</li>
<li><i class="fas fa-bullseye"></i> Vision, Mission & Objectives</li>
<li><i class="fas fa-sitemap"></i> Board of Directors</li>
<li><i class="fas fa-sitemap"></i> MPC Management</li>
<li><i class="fas fa-sitemap"></i> Organisational Structure</li>
<li><i class="fas fa-file-contract"></i> Quality Policy</li>
<li><i class="fas fa-list-alt"></i> Client Charter</li>
<li><i class="fas fa-file-contract"></i> No Gift Policy</li>
<li><i class="fas fa-file-contract"></i> Anti-Corruption Plan</li>
</ul>
</li>
<li>Contact Us
<ul>
<li><i class="fas fa-address-book"></i> How To Contact Us?</li>
<li><i class="fas fa-users"></i> Staff Directory</li>
<li><i class="fas fa-tasks"></i> Frequently Asked Question</li>
<li><i class="fas fa-briefcase"></i> Career</li>
<li><i class="fas fa-chart-area"></i> Procurement</li>
</ul>
</li>
<li>Staff Access
<ul>
<li><i class="fas fa-globe"></i> Staff Portal</li>
<li><i class="fas fa-globe"></i> Procurement Information Center (PRINCE)</li>
<li><i class="fas fa-globe"></i> Finance Portal</li>
</ul>
</li>
</ul>
</li>
<li>
<img src="/static_files/media_manager/1/Index-Programme-EN-1.png" class="img-desktop-vue">
PROGRAMMES & SERVICES
<ul>
<li>Productivity Initiatives
<ul>
<li><i class="fas fa-passport"></i> Industry4WRD Readiness Assessment</li>
<li><i class="fas fa-clipboard-check"></i> Team Excellence Convention</li>
<li><i class="fas fa-briefcase"></i> Lean Management</li>
<li><i class="fas fa-cubes"></i> Enterprise Business Excellence</li>
<li><i class="fas fa-award"></i> Productivity Excellence Recognition</li>
<li><i class="fas fa-user-tie"></i> MPC Certified Productivity Specialist Programme</li>
<li><i class="fas fa-poll"></i> Productivity Best Practices Case Studies and Sharing</li>
<li><i class="fas fa-balance-scale"></i> Productivity 1010</li>
<li><i class="fas fa-quote-left"></i> Negeri Produktif</li>
<li><i class="fas fa-puzzle-piece"></i> Malaysia Productivity Blueprint</li>
<li><i class="fas fa-people-carry"></i> Productivity Nexus</li>
</ul>
</li>
<li>Productivity Online Services
<ul>
<li><i class="fas fa-globe"></i> Digital Regulatory Notification</li>
<li><i class="fas fa-globe"></i> QE Audit Application (Quality Environment)</li>
<li><i class="fas fa-globe"></i> Benchmarking Online Networking Database (BOND) Portal</li>
<li><i class="fas fa-globe"></i> ezBE Assessment Tool</li>
<li><i class="fas fa-globe"></i> Unified Public Consultation (UPC) Portal</li>
<li><i class="fas fa-globe"></i> WayUp Portal</li>
<li><i class="fas fa-globe"></i> Smart Regulation (#MyMudah)</li>
</ul>
</li>
<li>Business Virtual Advisory Services (VAS)
<ul>
<li><i class="fas fa-business-time"></i> Business Virtual Advisory Clinics (VAC)</li>
</ul>
</li>
<li>MPC Webinar Sessions With Experts
<ul>
<li><i class="fas fa-chalkboard-teacher"></i> MPC Webinar Sessions With Experts</li>
</ul>
</li>
<li>P&I Associate Membership
<ul>
<li><i class="fas fa-users"></i> P&I Associate Membership</li>
</ul>
</li>
<li>Events Calendar
<ul>
<li><i class="far fa-calendar-alt"></i> Events Calendar</li>
</ul>
</li>
</ul>
</li>
<li>
<img src="/static_files/media_manager/1/Index-Productivity-EN-1.png" class="img-desktop-vue">
PRODUCTIVITY & COMPETITIVENESS
<ul>
<li>Smart Regulation Towards A Robust Ecosystem
<ul>
<li><i class="fas fa-business-time"></i> Business Regulation Virtual Advisory Clinic</li>
<li><i class="fas fa-landmark"></i> Good Regulatory Practice (GRP)</li>
</ul>
</li>
<li>Workforce Of The Future
<ul>
<li class="menushow"><i class="fas fa-thumbs-up"></i> e-Shared Prosperity Organization (eSPO)</li>
</ul>
</li>
<li>Digitalisation And Technology
<ul>
<li><i class="fas fa-chalkboard-teacher"></i> Digitalisation And Technology</li>
</ul>
</li>
<li>Productivity Mindset
<ul>
<li><i class="fas fa-user-friends"></i> Programme and Activity</li>
<li><i class="fas fa-users-cog"></i> Sejahtera Productivity Culture Index</li>
</ul>
</li>
<li>Incentive Structure
<ul>
<li><i class="fas fa-gifts"></i> Incentive Structure</li>
</ul>
</li>
</ul>
</li>
<li>
<img src="/static_files/media_manager/1/Index-Media-EN-1.png" class="img-desktop-vue">
MEDIA & PUBLICATION
<ul>
<li>Media
<ul>
<li><i class="far fa-newspaper"></i> Press Release</li>
<li><i class="far fa-comment-alt"></i> Speeches</li>
<li><i class="fas fa-music"></i> Audio Gallery</li>
<li><i class="fas fa-video"></i> Video Gallery</li>
<li><i class="fas fa-envelope-open-text"></i> e-Newsletter</li>
</ul>
</li>
<li>Publication
<ul>
<li><i class="fas fa-network-wired"></i> Productivity Performance</li>
<li><i class="fas fa-chart-bar"></i> Competitiveness Report</li>
<li><i class="fas fa-chart-line"></i> Annual Report</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
Here is what happen when I scroll when in mobile view: https://youtu.be/UzLTU-Dzhes
if you inspect in your website, you can see that there is a display none in the menu :
.menu-container {
width: 100%;
display: none;
}
remove it and everything will work fine
I am nearly done with this webpage and have some list items, but the li tags aren't inheriting the parent font. I have tried multiple ways to resolve it including using the ul and li tags to add inherit styling, but still no change. I've posted the code below. Thanks as always!
.section-plans {
background-color: #f4f4f4;
}
ul {
list-style: none;
}
.plan-box {
background-color: #fff;
border-radius: 5px;
width: 90%;
margin-left: 5%;
}
.plan-box div {
padding: 15px;
border-bottom: 1px solid #e8e8e8;
}
.residential {
font-size: 300%;
margin-bottom: 10px;
}
<div class="col span 1-of-3">
<div class="plan-box">
<div>
<h3>Commercial</h3>
<p class="residential"></p>
<ul>
<li><i class="far fa-check-circle">Clean & Disinfect</i></li>
<li><i class="far fa-check-circle">Emptry trash bins</i></li>
<li><i class="far fa-check-circle">Sweep & mop floor</i></li>
<li><i class="far fa-check-circle">Vaccum carpets & upholstry</i></li>
<li><i class="far fa-check-circle">Thoroughly wipe down handles & doors</i></li>
<li><i class="far fa-check-circle">Smudge free windown wipedown</i></li>
</ul>
</div>
<div>
Sign up now
</div>
Need to change in i tag close it before li text start instead of close end of the li text. Run code snippet
.section-plans {
background-color: #f4f4f4;
}
ul {
list-style: none;
}
.plan-box {
background-color: #fff;
border-radius: 5px;
width: 90%;
margin-left: 5%;
}
.plan-box div {
padding: 15px;
border-bottom: 1px solid #e8e8e8;
}
.residential {
font-size: 300%;
margin-bottom: 10px;
}
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<div class="col span 1-of-3">
<div class="plan-box">
<div>
<h3>Commercial</h3>
<p class="residential"></p>
<ul>
<li><i class="far fa-check-circle"></i> Clean & Disinfect</li>
<li><i class="far fa-check-circle"></i> Emptry trash bins </li>
<li><i class="far fa-check-circle"></i> Sweep & mop floor </li>
<li><i class="far fa-check-circle"></i> Vaccum carpets & upholstry </li>
<li><i class="far fa-check-circle"></i> Thoroughly wipe down handles & doors </li>
<li><i class="far fa-check-circle"></i> Smudge free windown wipedown </li>
</ul>
</div>
<div>
Sign up now
</div>
this because your i tag , you can fix it with add this line to your css
ul li i {
font-style: normal;
}
Please check the below snippet.
When a link goes on multiple lines, I'd like the text from all lines below the first one to be aligned with the start (left position) of the first line. The icon should still be vertically aligned with the first line (as it is now).
In other words, in the below example, the word "longer" should be aligned below the word "This".
I have tried playing with paddings and text-indents without success. Does anyone have a solution?
.column {
width: 150px;
background-color: lightgrey;
padding: 10px;
}
ul {
list-style: none;
padding-left: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="column">
<ul>
<li><span class="fa fa-fw fa-tree"></span> Hello</li>
<li><span class="fa fa-fw fa-car"></span> This is a much longer link</li>
<li><span class="fa fa-fw fa-book"></span> Hello again</li>
</ul>
</div>
Add this code in css..
.column li {
position: relative;
padding-left: 25px;
}
li span {
position: absolute;
left: 0;
top: 0;
}
.column {
width: 150px;
background-color: lightgrey;
padding: 10px;
}
ul {
list-style: none;
padding-left: 0;
}
.column li {
position: relative;
padding-left: 25px;
}
li span {
position: absolute;
left: 0;
top: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="column">
<ul>
<li><span class="fa fa-fw fa-tree"></span> Hello</li>
<li><span class="fa fa-fw fa-car"></span> This is a much longer link</li>
<li><span class="fa fa-fw fa-book"></span> Hello again</li>
</ul>
</div>
Just add display:flex to your li and it will work if you want the text to move further away from the icon then use margins too.
Hope this is what you are looking for.
.column {
width: 150px;
background-color: lightgrey;
padding: 10px;
}
ul {
list-style: none;
padding-left: 0;
}
li {
display: flex;
}
a {
margin-left: 10px;
}
.n {
width: 20px;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="column">
<ul>
<li>
<div class="n"><span class="fa fa-fw fa-tree"></span></div> Hello</li>
<li>
<div class="n"><span class="fa fa-fw fa-car"></span></div> This is a much longer link</li>
<li>
<div class="n"><span class="fa fa-fw fa-book"></span></div> Hello again</li>
</ul>
</div>
If we dont add width to icons and there is flex
.column {
width: 150px;
background-color: lightgrey;
padding: 10px;
}
ul {
list-style: none;
padding-left: 0;
}
li
{
display:flex;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="column">
<ul>
<li><span class="fa fa-fw fa-tree" style="background-color:blue;"></span> Hello</li>
<li><span class="fa fa-fw fa-car" style="background-color:blue;"></span> This is a much longer link</li>
<li><span class="fa fa-fw fa-book" style="background-color:blue;"></span> Hello again</li>
</ul>
</div>
As an alternative, you can also use a display: grid; layout on your li tag.
.column {
width: 150px;
background-color: lightgrey;
padding: 10px;
}
ul {
list-style: none;
padding-left: 0;
}
.column li {
display: grid;
grid-template-columns: auto 1fr;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="column">
<ul>
<li><span class="fa fa-fw fa-tree"></span> Hello</li>
<li><span class="fa fa-fw fa-car"></span> This is a much longer link</li>
<li><span class="fa fa-fw fa-book"></span> Hello again</li>
</ul>
</div>
I'm trying to align font awesome icons in the middle of the of the background image when I add position:relative; and use top:xxpx; it works but I want to figure out a way where I don't have to use position. Attached is a fiddle of my code, and a snippet below.
.footer-top {
height: 100px;
background-image: url("https://s4.postimg.org/714d8ul8d/footer-black.png");
}
.footer-top a {
text-decoration: none;
color: white;
}
.navbar-list {
padding-left: 540px;
display: inline;
}
.navbar-list:hover {
color: #fe5b1f;
cursor: pointer;
}
.navbar-icons {
display: inline;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="footer-top">
<ul class="navbar-list" id="icons-list">
<li class="navbar-icons">
<i class="fa fa-facebook-square fa-6" aria-hidden="true"></i>
</li>
<li class="navbar-icons">
<i class="fa fa-instagram fa-6" aria-hidden="true"></i>
</li>
<li class="navbar-icons">
<i class="fa fa-youtube-square fa-6" aria-hidden="true"></i>
</li>
</ul>
</div>
I would use display: flex; align-items: center; justify-content: center; on the parent to put the child in the dead center. Then use padding: 0 on the ul to remove the default left padding.
.footer-top {
height: 100px;
background-image: url("https://s4.postimg.org/714d8ul8d/footer-black.png");
display: flex;
align-items: center;
justify-content: center;
}
.footer-top a {
text-decoration: none;
color: white;
}
.navbar-list {
padding: 0;
}
.navbar-list:hover {
color: #fe5b1f;
cursor: pointer;
}
.navbar-icons {
display: inline;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="footer-top">
<ul class="navbar-list" id="icons-list">
<li class="navbar-icons"><i class="fa fa-facebook-square fa-6" aria-hidden="true"></i></li>
<li class="navbar-icons"><i class="fa fa-instagram fa-6" aria-hidden="true"></i></li>
<li class="navbar-icons"><i class="fa fa-youtube-square fa-6" aria-hidden="true"></i></li>
</ul>
</div>
You say you don't want to use position, but because it causes other elements to shift around on the page. If you use position: absolute on the ul, nothing else will move around because of that.
.footer-top {
height: 100px;
background-image: url("https://s4.postimg.org/714d8ul8d/footer-black.png");
position: relative;
}
.footer-top a {
text-decoration: none;
color: white;
}
.navbar-list {
padding: 0; margin: 0;
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
}
.navbar-list:hover {
color: #fe5b1f;
cursor: pointer;
}
.navbar-icons {
display: inline;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="footer-top">
<ul class="navbar-list" id="icons-list">
<li class="navbar-icons"><i class="fa fa-facebook-square fa-6" aria-hidden="true"></i></li>
<li class="navbar-icons"><i class="fa fa-instagram fa-6" aria-hidden="true"></i></li>
<li class="navbar-icons"><i class="fa fa-youtube-square fa-6" aria-hidden="true"></i></li>
</ul>
</div>
I am trying to achieve the following layout:
What I've now is:
How do I get li.company under the li.name?
I have tried to float the company li to the left and and making it the last li but that doesn't work keeps going to the same line. Any help will be appreciated.
Here is my code:
#flip {
padding: 5px;
background-color: #4d4d4f;
border: solid 1px #c3c3c3;
width: 33vw;
}
.contact-widget-list,
.sender-info {
list-style: none;
display: inline;
margin: 0;
padding: 0;
}
.sender-info {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
width: 30%;
}
.clearfix::after {
clear: both;
}
.sender-info li {
display: inline-block;
margin: 5px;
padding-bottom: 5px;
margin-bottom: 5px;
}
.email-icon,
.calander-icon,
.dropdown-icon {
float: right;
}
<div id="flip">
<ul class="sender-info">
<li class="name">Name 123123</li>
<li class="company">Company 123123</li>
<li class="dropdown-icon"><i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
</li>
<li class="calander-icon"><i class="fa fa-calendar" aria-hidden="true"></i>
</li>
<li class="email-icon"><i class="fa fa-envelope" aria-hidden="true"></i>
</li>
<li class="clearfix"></li>
</ul>
</div>
Just change the order of your HTML a bit. Place icons first in HTML and other items after it.
HTML:
<div id="flip">
<ul class="sender-info">
<!-- Following icons should come first in HTML -->
<li class="dropdown-icon"><i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
</li>
<li class="calander-icon"><i class="fa fa-calendar" aria-hidden="true"></i>
</li>
<li class="email-icon"><i class="fa fa-envelope" aria-hidden="true"></i>
</li>
<!-- Place following code after icons in HTML -->
<li class="name">Name 123123</li>
<li class="company">Company 123123</li>
</ul>
</div>
And add following css:
.sender-info .name,
.sender-info .company {
background: white;
overflow: hidden;
width: 200px;
}
#import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css");
#flip {
padding: 5px;
background-color: #4d4d4f;
border: solid 1px #c3c3c3;
}
.contact-widget-list,
.sender-info {
list-style: none;
display: inline;
overflow: hidden;
margin: 0;
padding: 0;
}
.sender-info {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
width: 30%;
}
.sender-info li {
margin: 5px;
padding-bottom: 5px;
}
.sender-info .name,
.sender-info .company {
background: white;
overflow: hidden;
width: 200px;
}
.email-icon,
.calander-icon,
.dropdown-icon {
float: right;
}
<div id="flip">
<ul class="sender-info">
<li class="dropdown-icon"><i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
</li>
<li class="calander-icon"><i class="fa fa-calendar" aria-hidden="true"></i>
</li>
<li class="email-icon"><i class="fa fa-envelope" aria-hidden="true"></i>
</li>
<li class="name">Name 123123</li>
<li class="company">Company 123123</li>
</ul>
</div>