Here is what I am trying to achieve
This is in my div's open state so normally you do not see any filters but instead just a full circle. What I am having trouble with is I dont know how to prevent a border on a small section.
Here is what I have below as well as a Codepen
.bold {
font-weight: bold;
}
.bp-purple {
color: #9696ff;
}
.bp-nyan {
color: #67cfd6;
}
.bp-pink {
color: #e49092;
}
.bp-green {
color: #96cf6b;
}
.filter-options {
text-align: center;
margin: 15px 0 0 0;
}
.filter-options__intro {
text-transform: uppercase;
display: inline-block;
border: 1px solid #222;
border-radius: 50%;
height: 80px;
width: 80px;
padding: 30px 0;
color: #222;
}
.filter-options__intro i {
margin: -5px 0 0 0;
display: block;
}
.filter-options__intro:hover {
color: #f93;
}
.filter-options__selections {
border: 1px solid #222;
position: relative;
bottom: 30px;
background: #FFF;
text-align: left;
padding: 15px;
margin: 0 0 -25px 0;
}
.filter-options__selections .list-inline, .filter-options__selections .checkbox {
font-weight: bold;
text-transform: uppercase;
}
.filter-options__selections input {
margin: 0;
}
.filter-options__selections .first {
font-size: 1.2em;
}
.filter-options__selections .dotted-line {
margin: 0 0 10px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="filter-options">
<a href="" class="filter-options__intro">
<b class="center-block">Filters</b>
<i class="fa fa-caret-down" aria-hidden="true"></i>
</a>
<div class="filter-options__selections clearfix">
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-purple">Categories:</li>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-nyan">Location:</li>
<li>Shanghai</li>
<li>Beijing</li>
<li>Hangzhou</li>
<li>Chengdu</li>
<li>Guangzhou</li>
<li>Shenzhen</li>
<li>Suzhou</li>
<li>Nanjing</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-pink">Brand:</li>
<li>Belle</li>
<li>St&Sat</li>
<li>Charles & Keith</li>
<li>Aldo</li>
<li>Daphne</li>
<li>Zara</li>
<li>Camel</li>
<li>Le Saunda</li>
<li>Tata</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-green">Price Range:</li>
<li>100 - 200</li>
<li>200 - 500</li>
<li>500 - 1000</li>
<li>1000 - 3000</li>
</ul>
</div>
<div class="dotted-line"></div>
<div class="checkbox">
<label>
<input type="checkbox" /> Show only free shipping products
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" /> Do not show international products
</label>
</div>
<div class="dotted-line"></div>
</div>
</div>
</div>
Edit
Added sass tag as my codepen is in sass but not sure if stack lets me use it in snippets
First you need to make <a> position relatively.
.filter-options__intro {
position: relative;
}
Then add an css after selector, to cover up the black line
a.filter-options__intro:after {
content: '';
display: block;
background: white;
z-index: 1111;
position: absolute;
width: 75px;
height: 1px;
bottom: 0px;
left: 0;
right: 0;
margin: auto;
top: 20px;
}
Working example:
Overlap element using CSS :after
Tried something that might help you:
Position the whole DOM of the link relative.
I had to use three DOM Elements to make it look like your output.
Positioned the content at z-index: 1.
Positioned others in higher z-index.
Gave a faux background.
* {
margin: 0;
padding: 0;
list-style: none;
line-height: 1;
text-decoration: none;
}
body {
background-color: #fff;
}
.center {
text-align: center;
position: relative;
z-index: 5;
}
.faux-cutter {
text-align: center;
display: inline-block;
overflow: hidden;
height: 30px;
border-bottom: 1px solid #fff;
position: relative;
z-index: 3;
background-color: #fff;
bottom: -2px;
}
.border {
padding: 10px 20px 30px;
display: inline-block;
border: 1px solid #666;
border-radius: 100%;
position: relative;
z-index: 4;
}
.content {
border: 1px solid #666;
padding: 25px;
text-align: center;
top: -2px;
position: relative;
z-index: 1;
}
<div class="center">
<div class="faux-cutter">
Hi
</div>
</div>
<div class="content">
Content here.
</div>
Preview
I would layer the semi-circle over the rectangle, and then I would add an inner absolutely positioned div to hide the bottom of the filters circle. You could do something like this:
.bold {
font-weight: bold;
}
.bp-purple {
color: #9696ff;
}
.bp-nyan {
color: #67cfd6;
}
.bp-pink {
color: #e49092;
}
.bp-green {
color: #96cf6b;
}
.filter-options {
text-align: center;
margin: 15px 0 0 0;
}
.filter-options__intro {
text-transform: uppercase;
display: inline-block;
border: 1px solid #222;
border-radius: 50%;
height: 80px;
width: 80px;
background: white;
padding: 30px 0;
margin-bottom: -25px;
color: #222;
}
.filter-options__intro i {
margin: -5px 0 0 0;
display: block;
}
.filter-options__intro:hover {
color: #f93;
}
.filter-options__selections {
border-top: 1px solid #222;
background: #FFF;
text-align: left;
}
.filter-options__selections-inner {
position:absolute;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
left: 15px;
right: 15px;
background: white;
padding: 15px;
}
.filter-options__selections .list-inline,
.filter-options__selections .checkbox {
font-weight: bold;
text-transform: uppercase;
}
.filter-options__selections input {
margin: 0;
}
.filter-options__selections .first {
font-size: 1.2em;
}
.filter-options__selections .dotted-line {
margin: 0 0 10px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="filter-options">
<a href="" class="filter-options__intro">
<b class="center-block">Filters</b>
<i class="fa fa-caret-down" aria-hidden="true"></i>
</a>
<div class="filter-options__selections clearfix">
<div class="filter-options__selections-inner">
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-purple">Categories:</li>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-nyan">Location:</li>
<li>Shanghai</li>
<li>Beijing</li>
<li>Hangzhou</li>
<li>Chengdu</li>
<li>Guangzhou</li>
<li>Shenzhen</li>
<li>Suzhou</li>
<li>Nanjing</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-pink">Brand:</li>
<li>Belle</li>
<li>St&Sat</li>
<li>Charles & Keith</li>
<li>Aldo</li>
<li>Daphne</li>
<li>Zara</li>
<li>Camel</li>
<li>Le Saunda</li>
<li>Tata</li>
</ul>
<a class="pull-right bold" href="">View All <i class="fa fa-caret-right" aria-hidden="true"></i></a>
</div>
<div class="dotted-line"></div>
<div class="clearfix">
<ul class="list-inline pull-left">
<li class="first bp-green">Price Range:</li>
<li>100 - 200</li>
<li>200 - 500</li>
<li>500 - 1000</li>
<li>1000 - 3000</li>
</ul>
</div>
<div class="dotted-line"></div>
<div class="checkbox">
<label>
<input type="checkbox" />Show only free shipping products
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" />Do not show international products
</label>
</div>
<div class="dotted-line"></div>
</div>
</div>
</div>
</div>
You can't disable a portion of the border. I'd suggest adding a span to mask that particular part of the border with a small rectangular shape and z-index. Here is a forked pen with my changes.
I added a span with the class of 'mask' directly within your .filter-options div. <span class="mask"></span>.
Adding some CSS allowed me to build the shape of the mask using a solid white block. It will work as long as the background color remains white.
.mask {
background-color: white;
position: relative;
top: 4px;
z-index: 2;
width: 77px;
height: 3px;
display: block;
}
Related
I am creating a Twitter clone but the sidebar moves down when I create the main page contents. I tried using Position - fixed and relative but still the same issue. Before I added the main page content, the sidebar was correctly positioned (please see screenshot) but as soon as its added, the sidebar moves down(please see screenshot).
I'm using Grid to create the three columns to give the Twitter aesthetics.
What am I doing wrong?
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.twitter-logo {
height: 28px;
filter: invert(52%) sepia(50%) saturate(2964%) hue-rotate(179deg) brightness(95%) contrast(97%);
margin-left: 25px;
}
.left-sidebar {
/* position: fixed; */
position: relative;
}
.navbar-brand:hover {
background: rgba(29, 161, 242, 0.1);
border-radius: 50%;
color: #1da0f2;
margin-right: 23px;
/* padding: 20px; */
}
.left-sidebar-menu {
font-size: 20px;
cursor: pointer;
font-weight: 700;
display: flex;
color: rgb(15, 20, 25);
font-family: 'Times New Roman', Times, serif;
}
.left-sidebar-menu-icon {
align-items: flex-start;
height: 26px;
margin-right: 20px;
}
.nav-item {
padding: 10px;
margin: 2px 2px;
}
.nav-item:hover {
background: rgba(29, 161, 242, 0.1);
border-radius: 20px;
color: #1da0f2;
}
/* --------------------------------MAIN PAGE------ */
.main-page-header {
font-size: 18px;
height: 48px;
font-weight: 700;
font-family: 'Open Sans', sans-serif;
}
.main-page-header-profile-picture {
border-radius: 50%;
height: 48px;
}
.main-page-input {
border: 0 solid black;
}
.main-page-input-box {
padding-top: 10px;
border-bottom: 1px solid #e6e6e6;
}
.main-page-tweet-box {
margin-top: -5px;
word-wrap: break-word;
word-break: break-all;
outline: none;
}
.main-page-tweet-box:focus main-page-tweet-box:hover {
outline: none !important;
box-shadow: none;
border: 0;
}
.main-page-tweet-box {
height: 130px;
border: 0;
margin-top: -10px;
}
::placeholder {
font-family: 'Open Sans', sans-serif;
opacity: 1;
font-size: 18px;
/* position: absolute;
margin-top: 10px; */
}
.main-page-input-privacy {
/* display: flex;
align-items: flex-start; */
display: inline-block;
color: #1da1f2;
cursor: pointer;
}
.main-page-input-privacy-icon,
main-page-input-privacy-text {
display: inline;
}
/* .main-page-input-privacy i{
float: left;
} */
.main-page-input-icons {
display: flex;
justify-content: space-between;
margin-left: -35PX;
}
.main-page-input-icons-ul {
list-style-type: none;
margin-left: 5px;
}
.main-page-input-icons li {
display: inline;
/* width: 300px; */
list-style: none;
color: #1da1f2;
font-size: 20px;
margin: 0 2px;
height: 38px;
width: 38px;
cursor: pointer;
}
.main-page-tweet-button {
font-size: 16px;
font-family: 'Open Sans', sans-serif;
color: white;
background-color: #1da1f2;
text-align: center;
cursor: pointer;
/* width: 75px; */
/* height: 30px; */
border: none;
outline: none;
opacity: 0.5;
}
/* .main-page-input form {
} */
/* .left-sidebar-menu-icon-active using js {
filter: invert(52%) sepia(50%) saturate(2964%) hue-rotate(179deg) brightness(95%) contrast(97%);
} */
/* .left-sidebar-menu-btn {
} */
.tweetbox__input img {
border-radius: 50%;
height: 40px;
}
.tweetBox {
padding-bottom: 10px;
border-bottom: 8px solid var(--twitter-background);
padding-right: 10px;
}
.tweetBox form {
display: flex;
flex-direction: column;
}
.tweetbox__input {
display: flex;
padding: 20px;
}
.tweetbox__input input {
flex: 1;
margin-left: 20px;
font-size: 20px;
border: none;
outline: none;
}
.tweetBox__tweetButton {
background-color: var(--twitter-color);
border: none;
color: white;
font-weight: 900;
border-radius: 30px;
width: 80px;
height: 40px;
margin-top: 20px;
margin-left: auto;
}
.tweet {
display: flex;
margin-bottom: 4px;
border-bottom: 1px solid rgb(47, 51, 54);
cursor: pointer;
}
.tweet-author-image {
border-radius: 50%;
height: 48px;
width: 48px;
margin-right: 12px;
}
.tweet-feed-content {
margin-bottom: 15px;
padding-bottom: 12px;
}
.tweet-header {
display: flex;
font-size: 15px;
font-weight: 400;
}
.tweet-author-username {
font-family: 'Times New Roman', Times, serif;
/* color: rgb(231, 233, 234); */
}
.tweet-author-handle {
color: rgb(113, 118, 123);
}
.tweeted-time {
color: rgb(113, 118, 123);
}
.engagement-icons-ul {
display: flex;
list-style-type: none;
justify-content: space-between;
margin-left: -30px;
width: 400px;
}
<div class="container">
<div class="row">
<div class="col-3 navbar">
<nav>
<div class="left-sidebar">
<a class="navbar-brand" href="#">
<img src={ % static 'network/images/brand.svg' %} alt="Twitter logo" class="twitter-logo">
</a>
<ul class="nav flex-column left-sidebar-menu mb-4 mt-2">
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/all-post.svg' %} alt="All post" class="left-sidebar-menu-icon"> All Post
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/following.svg' %} alt="Following" class="left-sidebar-menu-icon"> Following
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/notifications.svg' %} alt="Notifications" class="left-sidebar-menu-icon"> Notifications
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/messages.svg' %} alt="Messages" class="left-sidebar-menu-icon"> Messages
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/profile.svg' %} alt="Profile" class="left-sidebar-menu-icon"> Profile
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src={ % static 'network/images/more.svg' %} alt="More" class="left-sidebar-menu-icon"> More
</a>
</li>
<button class="btn btn-primary rounded-pill my-2 py-3">Tweet</button>
</ul>
</div>
</nav>
</div>
<div class="col-5">
<div class="main-page-header mt-3 sticky-top">Home</div>
<div class="main-page-input">
<!-- <form class="d-flex flex-column"> -->
<div class="row">
<div class="col-2 main-page-header-profile-picture">
<img src="https://i.pinimg.com/originals/a6/58/32/a65832155622ac173337874f02b218fb.png" class="main-page-header-profile-picture" alt="profile-picture" />
</div>
<div class="col-10">
<div class="main-page-input-box">
<div>
<textarea name="tweet-box" id="" class="form-control main-page-tweet-box text-wrap" cols="30" rows="10" placeholder="What's happening"></textarea>
<!-- <input type="text" class="form-control main-page-tweet-box text-wrap" id="exampleFormControlInput1" placeholder="What's happening"> -->
</div>
<div class="main-page-input-privacy pb-2 mt-3">
<i class="fas fa-globe-americas main-page-input-privacy-icon"></i>
<span class="ain-page-input-privacy-text ml-2">Everyone can reply</span>
</div>
</div>
<div class="main-page-input-icons mt-3">
<ul class="main-page-input-icons-ul">
<li><i class="fa-solid fa-image"></i></li>
<li><i class="fa-solid fa-square-poll-horizontal"></i></li>
<li><i class="fa-solid fa-face-grin"></i></li>
<li><i class="fa-regular fa-calendar"></i></li>
<li><i class="fa-solid fa-location-dot"></i></li>
</ul>
<button type="submit" class="btn btn-primary rounded-pill px-4 main-page-tweet-button"><strong>Tweet</strong></button>
</div>
</div>
</div>
<!-- </form> -->
</div>
<div class="tweet-feed">
<div class="tweet">
<img src="http://placeimg.com/140/140/people" alt="author profile picture" class="tweet-author-image" />
<div class="tweet-feed-content">
<div class="tweet-header">
Nick Huber
<div class="tweet-author-handle">#sweatystartup</div>
<div class="tweeted-time">8h</div>
</div>
<div class="tweet-content">
<div class="tweet-created-content">It is a wonderful day</div>
</div>
<div class="engagement-icons">
<ul class="engagement-icons-ul">
<li><i class="fa-regular fa-comment"></i></li>
<li><i class="fa-solid fa-retweet"></i></li>
<li><i class="fa-regular fa-heart"></i></li>
<li><i class="fa-solid fa-arrow-up-from-bracket"></i></li>
</ul>
</div>
</div>
</div>
<div class="tweet">
<img src="http://placeimg.com/140/140/animals" alt="author profile picture" class="tweet-author-image" />
<div class="tweet-feed-content">
<div class="tweet-header">
Randall
<div class="tweet-author-handle">#RandallKanna</div>
<div class="tweeted-time">18h</div>
</div>
<div class="tweet-content">
<div class="tweet-created-content">Hey friends</div>
<img src="http://placeimg.com/300/300/tech" alt="tweeter feed" />
</div>
</div>
</div>
</div>
</div>
<div class="col-4">
TODO
</div>
</div>
</div>
Basically, i'm creating a custom select box when i finished the design part using css and when i wanted to add the "before" and "active" options so that the "arrow" and "menu" changes when the select box is active, I had some problems, when i add "active" to the class name in the browser the arrow is supposed to rotate but nothing happens instead.
HTML
<div class="custom_select_box_1_index">
<ul id="DefaultCategoryIndex"class="default_option_category_index">
<li>
<div class="option_allcategories">
<p>All Categories</p>
<i id="ArrowCategoryIndex" class="fa fa-chevron-up"></i>
</div>
</li>
</ul>
<ul id="OptionsCategoryIndex" class="select_option_category_index">
<li>
<div id="CategoryObjects" class="option objects">
<div class="icon"><i id="icon" class="fas fa-cube"></i></div>
<p class="category_text">Objects</p>
</div>
</li>
<li>
<div id="CategoryVehicules" class="option vehicules">
<div class="icon"><i id="icon" class="fas fa-car"></i></div>
<p class="category_text">Vehicules</p>
</div>
</li>
<li>
<div id="CategoryTechnology" class="option technology">
<div class="icon"><i id="icon" class="fas fa-mobile"></i></div>
<p class="category_text">Technology</p>
</div>
</li>
<li>
<div id="CategoryBooks" class="option books">
<div class="icon"><i id="icon" class="fas fa-book"></i></div>
<p class="category_text">Books</p>
</div>
</li>
<li>
<div id="CategoryGaming" class="option gaming">
<div class="icon"><i id="icon" class="fas fa-gamepad"></i></div>
<p class="category_text">Gaming</p>
</div>
</li>
<li>
<div id="CategoryOther" class="option other">
<div class="icon"><i id="icon" class="fas fa-ellipsis-h"></i></div>
<p class="category_text">Other...</p>
</div>
</li>
</ul>
</div>
CSS:
.custom_select_box_1_index{
font-family: Helvetica;
font-size: 19px;
color: var(--second-black);
box-sizing: content-box;
width: 250px;
height: 50px;
}
.custom_select_box_1_index > ul li{
list-style: none;
}
.custom_select_box_1_index .default_option_category_index:before{
content: "";
padding-top: 1px;
padding-bottom: 1px;
border-radius: 10px;
background-color: var(--white);
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.05);
cursor: pointer;
transform: rotate(180deg);
color: var(--black);
position: absolute;
margin-left: 170px;
margin-top: -39px;
cursor: pointer;
}
.custom_select_box_1_index .select_option_category_index{
background-color: var(--white);
border-radius: 10px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.05);
z-index: 1;
display: none
}
.select_option_category_index li{
position: relative;
margin-left: -38px;
background-color: var(--white);
border-radius: 10px;
width: 230px;
padding: 3px 8px;
cursor: pointer;
}
.custom_select_box_1_index .select_option_category_index li:hover{
background: var(--grey);
}
.category_text{
position: relative;
left: 30px;
}
.custom_select_box_1_index .option{
display: flex;
align-items: center;
}
.icon{
display: flex;
align-items: center;
margin-left: 15px;
}
#icon{
color: var(--black);
}
.custom_select_box_1_index:active .select_option_category_index{
display: block;
}
.custom_select_box_1_index:active .default_option_category_index:before{
transform: rotate(0deg);
}
I want the arrow to rotate back to 0deg when the select bar is active (without using JavaScript).
You can leverage the CSS adjacent sibling selector +:
.custom_select_box_1_index {
font-family: Helvetica;
font-size: 19px;
color: var(--second-black);
box-sizing: content-box;
width: 250px;
height: 50px;
}
.custom_select_box_1_index>ul li {
list-style: none;
}
.custom_select_box_1_index .default_option_category_index:before {
content: "";
padding-top: 1px;
padding-bottom: 1px;
border-radius: 10px;
background-color: var(--white);
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.05);
cursor: pointer;
transform: rotate(180deg);
color: var(--black);
position: absolute;
margin-left: 170px;
margin-top: -39px;
cursor: pointer;
}
.custom_select_box_1_index .select_option_category_index {
background-color: var(--white);
border-radius: 10px;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.05);
z-index: 1;
display: none
}
.select_option_category_index li {
position: relative;
margin-left: -38px;
background-color: var(--white);
border-radius: 10px;
width: 230px;
padding: 3px 8px;
cursor: pointer;
}
.custom_select_box_1_index .select_option_category_index li:hover {
background: var(--grey);
}
.category_text {
position: relative;
left: 30px;
}
.custom_select_box_1_index .option {
display: flex;
align-items: center;
}
.icon {
display: flex;
align-items: center;
margin-left: 15px;
}
#icon {
color: var(--black);
}
.custom_select_box_1_index:active .select_option_category_index {
display: block;
}
.custom_select_box_1_index:active .default_option_category_index:before {
transform: rotate(90deg);
}
.option_allcategories p:active+.fa-chevron-up {
transform: rotate(180deg);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<div class="custom_select_box_1_index">
<ul id="DefaultCategoryIndex" class="default_option_category_index">
<li>
<div class="option_allcategories">
<p>All Categories</p>
<i id="ArrowCategoryIndex" class="fa fa-chevron-up"></i>
</div>
</li>
</ul>
<ul id="OptionsCategoryIndex" class="select_option_category_index">
<li>
<div id="CategoryObjects" class="option objects">
<div class="icon"><i id="icon" class="fas fa-cube"></i></div>
<p class="category_text">Objects</p>
</div>
</li>
<li>
<div id="CategoryVehicules" class="option vehicules">
<div class="icon"><i id="icon" class="fas fa-car"></i></div>
<p class="category_text">Vehicules</p>
</div>
</li>
<li>
<div id="CategoryTechnology" class="option technology">
<div class="icon"><i id="icon" class="fas fa-mobile"></i></div>
<p class="category_text">Technology</p>
</div>
</li>
<li>
<div id="CategoryBooks" class="option books">
<div class="icon"><i id="icon" class="fas fa-book"></i></div>
<p class="category_text">Books</p>
</div>
</li>
<li>
<div id="CategoryGaming" class="option gaming">
<div class="icon"><i id="icon" class="fas fa-gamepad"></i></div>
<p class="category_text">Gaming</p>
</div>
</li>
<li>
<div id="CategoryOther" class="option other">
<div class="icon"><i id="icon" class="fas fa-ellipsis-h"></i></div>
<p class="category_text">Other...</p>
</div>
</li>
</ul>
</div>
Before I start, I understand that linear-gradients cannot be transitioned through the traditional transition in CSS. I know that gradients are treated as images. Here is my problem. I have a navbar in my website. I am working with materialize css as my framework. When a user visits my website, the navbar is a transparent white color, as the user scrolls, I would like my navbar to transition at a certain point, to the linear gradient. Would this be possible? Here is my markup:
$(document).ready(function(){
$('.sidenav').sidenav();
const parallax = () => {
let wScroll = $(window).scrollTop();
if (wScroll > 400) {
$("nav").addClass("bgchange");
} else {
$("nav").removeClass("bgchange");
}
};
parallax();
$(window).scroll(function() {
parallax();
});
});
.navlogo {
position: relative;
height: 55px !important;
width: 55px !important;
margin-top: 10px;
}
.bgchange {
z-index: 10;
background: linear-gradient(to right, #00BAA3, #1565c0) !important;
}
.navbar-fixed {position: absolute; z-index:10;}
.trans{
background-color: rgba(255,255,255,0.25) !important;
transition: all 0.7s ease-in-out;
}
input {
outline-style:none;
box-shadow:none;
border-color:transparent;
}
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 40px white inset !important;
}
.sidenav .user-view .background img {
width: 100%;
height: 100%;
position: relative;
}
.sidenav .user-view {
height: 240px;
background-color: rgba(0, 0, 0, 0.5);
}
.name {
display: inline-block;
line-height: 15px;
}
.sale {
text-transform: uppercase;
font-weight: 900;
margin: 0 0 1rem;
padding: 0;
line-height: 1;
font-family: Futura, Helvetica, sans-serif;
font-size: 26px;
}
.brand-logo .text {
display: inline-block;
position: absolute;
margin-top: 18px;
margin-left: 5px;
text-transform: uppercase;
font-weight: 900;
padding: 0;
line-height: 1;
font-family: Futura, Helvetica, sans-serif;
font-size: 26px;
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css" rel="stylesheet"/>
<div class="navbar-fixed">
<nav class='trans'>
<div class="nav-wrapper">
<img class='navlogo' src="static/images/IMG_6970.png" alt=""><span class="text">Dog<span>House</span></span>
<i class="material-icons">menu</i>
<ul class="right hide-on-med-and-down">
<li>Login</li>
<li>Sign up</li>
<li>
<form>
<div class="input-field">
<input id="search" type="search" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
</li>
</ul>
</div>
</nav>
</div>
<ul class="sidenav " id="mobile-demo">
<li><div class="user-view">
<div class="background">
<img src="static/images/IMG_6971.png">
</div>
<div class="center center-align">
<span class="white-text sale">DogHouse</span>
<span class="white-text name">The only app you will need for when you are on your dream vacation.</span>
<span class="white-text email"><br>doghouse#gmail.com</span>
</div>
</div></li>
<li><i class="material-icons">supervisor_account</i> Login</li>
<li>
<form>
<div class="input-field">
<input id="search" type="search" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
</li>
</ul>
Rather than trying to animate the background gradient, I suggest you create a pseudo element on your navigation, absolutely positioned with a z-index of 0. Then just transition the opacity of the pseudo element.
Below is the updated code, it's worth noting I only changed the CSS:
$(document).ready(function() {
$('.sidenav').sidenav();
const parallax = () => {
let wScroll = $(window).scrollTop();
if (wScroll > 400) {
$("nav").addClass("bgchange");
} else {
$("nav").removeClass("bgchange");
}
};
parallax();
$(window).scroll(function() {
parallax();
});
});
.navlogo {
position: relative;
height: 55px !important;
width: 55px !important;
margin-top: 10px;
}
.bgchange {
z-index: 10;
/* this is now being applied to the pseudo element */
/* background: linear-gradient(to right, #00baa3, #1565c0) !important; */
}
.navbar-fixed {
position: absolute;
z-index: 10;
}
.trans {
background-color: rgba(255, 255, 255, 0.25) !important;
/* this is now being applied to the pseudo element */
transition: all 0.7s ease-in-out;
}
input {
outline-style: none;
box-shadow: none;
border-color: transparent;
}
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 40px white inset !important;
}
.sidenav .user-view .background img {
width: 100%;
height: 100%;
position: relative;
}
.sidenav .user-view {
height: 240px;
background-color: rgba(0, 0, 0, 0.5);
}
.name {
display: inline-block;
line-height: 15px;
}
.sale {
text-transform: uppercase;
font-weight: 900;
margin: 0 0 1rem;
padding: 0;
line-height: 1;
font-family: Futura, Helvetica, sans-serif;
font-size: 26px;
}
.brand-logo .text {
display: inline-block;
position: absolute;
margin-top: 18px;
margin-left: 5px;
text-transform: uppercase;
font-weight: 900;
padding: 0;
line-height: 1;
font-family: Futura, Helvetica, sans-serif;
font-size: 26px;
}
/* pseudo element */
.trans::before {
background: linear-gradient(to right, #00baa3, #1565c0);
bottom: 0;
content: '';
display: block;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transition: all 0.7s ease-in-out;
z-index: 0;
}
.trans.bgchange::before {
opacity: 1;
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css" rel="stylesheet" />
<div class="navbar-fixed">
<nav class='trans'>
<div class="nav-wrapper">
<a href="#!" class="brand-logo "><img class='navlogo' src="static/images/IMG_6970.png" alt=""><span class="text">Dog<span>House</span></span>
</a>
<i class="material-icons">menu</i>
<ul class="right hide-on-med-and-down">
<li>Login</li>
<li>Sign up</li>
<li>
<form>
<div class="input-field">
<input id="search" type="search" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
</li>
</ul>
</div>
</nav>
</div>
<ul class="sidenav " id="mobile-demo">
<li>
<div class="user-view">
<div class="background">
<img src="static/images/IMG_6971.png">
</div>
<div class="center center-align">
<span class="white-text sale">DogHouse</span>
<span class="white-text name">The only app you will need for when you are on your dream vacation.</span>
<span class="white-text email"><br>doghouse#gmail.com</span>
</div>
</div>
</li>
<li><i class="material-icons">supervisor_account</i> Login</li>
<li>
<form>
<div class="input-field">
<input id="search" type="search" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
</li>
</ul>
CodePen example: https://codepen.io/samwalker/pen/KeOXBa
So I have an interface where I want a sidemenu to the left, and the rest of the area should contain a chat-field. The problem is that the chat-field is overflowing the container, and half of the chat-field goes outside the container div.
How do I fit the chat-field in the container with these settings? The container is named #chat-canvas
Here's a JSFiddle: https://jsfiddle.net/v5k1Lhgf/1/
* {
margin: 0;
padding: 0;
box-sizing: border-box !important;
}
html, body, #body {
background-color: #ffffff;
font-size: 15px;
color: #565656;
width: 100%;
padding: 0;
margin-left: 0;
margin-right: 0;
font-family: 'roboto', sans-serif;
font-weight: 300;
}
#body, .app html, body {
background-color: #f9f9f9;
font-size: 15px;
color: #565656;
width: 100%;
height: 100%;
padding: 0;
margin-left: 0;
margin-right: 0;
font-family: 'roboto', sans-serif;
font-weight: 300;
min-height: 100%;
}
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
transition: all 3s ease-in-out;
height: 100%;
min-height: 100%;
}
*,*:before,*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#chat-canvas {
width: 94% !important;
height: 100%;
position: absolute;
float: left;
display: inline-block;
overflow: hidden;
}
.app-nav {
position: relative;
height: 100%;
width: 6%;
display: inline-block;
}
.tl-menu {
position: absolute;
overflow: hidden;
float: left;
top: 0;
height: 100%;
list-style-type: none;
margin: 0;
padding: 0;
background: #1b1e24;
z-index: 9999;
}
.tl-menu img{
max-height: 80%;
}
.tl-menu li a {
display: block;
height: 5em;
width: 5em;
line-height: 5em;
text-align: center;
color: #999;
position: relative;
border-bottom: 1px solid rgba(104,114,134,0.05);
-webkit-transition: background 0.1s ease-in-out;
-moz-transition: background 0.1s ease-in-out;
transition: background 0.1s ease-in-out;
}
.tl-menu li a:hover,
.tl-menu li:first-child a{
color: #55fec6;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.tl-menu li a:active {
background: #afdefa;
color: #FFF;}
/* class for current item */
.tl-menu li.tl-current a {
background: #343a47;
color: #bbe6fe;
}
.tl-menu li a:before {
font-family: 'entypo', sans-serif;
speak: none;
font-style: normal;
font-weight: normal;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 1.4em;
-webkit-font-smoothing: antialiased;
}
.tl-menu li a.icon-logo:before {
font-weight: 700;
font-size: 300%;
}
/* ---------- CHAT ---------- */
.people-list {
width: 30%;
float: right;
}
.people-list .search {
padding: 20px;
}
.people-list input {
border-radius: 3px;
border: none;
padding: 14px;
color: white;
background: #6A6C75;
width: 90%;
font-size: 14px;
}
.people-list .fa-search {
position: relative;
left: -25px;
}
.people-list ul {
padding: 20px;
height: 770px;
}
.people-list ul li {
padding-bottom: 20px;
}
.people-list img {
float: left;
}
.people-list .about {
float: left;
margin-top: 8px;
}
.people-list .about {
padding-left: 8px;
}
.people-list .status {
color: #92959E;
}
.chat {
width: 70%;
float: left;
position: absolute;
background: #F2F5F8;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
color: #434651;
}
.chat .chat-header {
padding: 20px;
border-bottom: 2px solid white;
}
.chat .chat-header img {
float: left;
}
.chat .chat-header .chat-about {
float: left;
padding-left: 10px;
margin-top: 6px;
}
.chat .chat-header .chat-with {
font-weight: bold;
font-size: 16px;
}
.chat .chat-header .chat-num-messages {
color: #92959E;
}
.chat .chat-header .fa-star {
float: right;
color: #D8DADF;
font-size: 20px;
margin-top: 12px;
}
.chat .chat-history {
padding: 30px 30px 20px;
border-bottom: 2px solid white;
overflow-y: scroll;
height: 575px;
}
.chat .chat-history .message-data {
margin-bottom: 15px;
}
.chat .chat-history .message-data-time {
color: #a8aab1;
padding-left: 6px;
}
.chat .chat-history .message {
color: white;
padding: 18px 20px;
line-height: 26px;
font-size: 16px;
border-radius: 7px;
margin-bottom: 30px;
width: 90%;
position: relative;
}
.chat .chat-history .message:after {
bottom: 100%;
left: 7%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-bottom-color: #86BB71;
border-width: 10px;
margin-left: -10px;
}
.chat .chat-history .my-message {
background: #86BB71;
}
.chat .chat-history .other-message {
background: #94C2ED;
}
.chat .chat-history .other-message:after {
border-bottom-color: #94C2ED;
left: 93%;
}
.chat .chat-message {
padding: 30px;
}
.chat .chat-message textarea {
width: 100%;
border: none;
padding: 10px 20px;
font: 14px/22px "Lato", Arial, sans-serif;
margin-bottom: 10px;
border-radius: 5px;
resize: none;
}
.chat .chat-message .fa-file-o, .chat .chat-message .fa-file-image-o {
font-size: 16px;
color: gray;
cursor: pointer;
}
.chat .chat-message button {
float: right;
color: #94C2ED;
font-size: 16px;
text-transform: uppercase;
border: none;
cursor: pointer;
font-weight: bold;
background: #F2F5F8;
}
.chat .chat-message button:hover {
color: #75b1e8;
}
.online, .offline, .me {
margin-right: 3px;
font-size: 10px;
}
.online {
color: #86BB71;
}
.offline {
color: #E38968;
}
.me {
color: #94C2ED;
}
.align-left {
text-align: left;
}
.align-right {
text-align: right;
}
.float-right {
float: right;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.chat-container {
bottom: 0;
left: 0;
right: 0;
height: auto;
margin: 0 auto;
width: 750px;
background: #444753;
border-radius: 5px;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<body class="app">
<!-- NAV -->
<div class="app-nav">
<ul class="tl-menu">
<li><img src="https://i.imgur.com/ngO5Ohx.png" alt="Mendr Logo" height="50" width="50"></li>
<li><img src="{{user.picture}}"></li>
<li><i class="fa fa-plus" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-wechat" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-map" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-search" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-sign-out" style="font-size:30px; margin-top:20px;"></i></li>
</ul>
</div>
<!-- END NAV -->
<!-- CHAT -->
<div id="chat-canvas">
<div class="clearfix chat-container">
<div class="people-list" id="people-list">
<div class="search">
<input type="text" placeholder="search" />
<i class="fa fa-search"></i>
</div>
<ul class="list">
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01.jpg" alt="avatar" />
<div class="about">
<div class="name">Vincent Porter</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_02.jpg" alt="avatar" />
<div class="about">
<div class="name">Aiden Chavez</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 7 mins ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_03.jpg" alt="avatar" />
<div class="about">
<div class="name">Mike Thomas</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_04.jpg" alt="avatar" />
<div class="about">
<div class="name">Erica Hughes</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_05.jpg" alt="avatar" />
<div class="about">
<div class="name">Ginger Johnston</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_06.jpg" alt="avatar" />
<div class="about">
<div class="name">Tracy Carpenter</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 30 mins ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_07.jpg" alt="avatar" />
<div class="about">
<div class="name">Christian Kelly</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 10 hours ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_08.jpg" alt="avatar" />
<div class="about">
<div class="name">Monica Ward</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_09.jpg" alt="avatar" />
<div class="about">
<div class="name">Dean Henry</div>
<div class="status">
<i class="fa fa-circle offline"></i> offline since Oct 28
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_10.jpg" alt="avatar" />
<div class="about">
<div class="name">Peyton Mckinney</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
</ul>
</div>
<div class="activity-info">
<div class="chat">
<div class="chat-header clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01_green.jpg" alt="avatar" />
<div class="chat-about">
<div class="chat-with">Chat with Vincent Porter</div>
<div class="chat-num-messages">already 1 902 messages</div>
</div>
<i class="fa fa-star"></i>
</div> <!-- end chat-header -->
<div class="chat-history">
<ul>
<li class="clearfix">
<div class="message-data align-right">
<span class="message-data-time" >10:10 AM, Today</span>
<span class="message-data-name" >Olia</span> <i class="fa fa-circle me"></i>
</div>
<div class="message other-message float-right">
Hi Vincent, how are you? How is the project coming along?
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:12 AM, Today</span>
</div>
<div class="message my-message">
Are we meeting today? Project has been already finished and I have results to show you.
</div>
</li>
<li class="clearfix">
<div class="message-data align-right">
<span class="message-data-time" >10:14 AM, Today</span>
<span class="message-data-name" >Olia</span> <i class="fa fa-circle me"></i>
</div>
<div class="message other-message float-right">
Well I am not sure. The rest of the team is not here yet. Maybe in an hour or so? Have you faced any problems at the last phase of the project?
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:20 AM, Today</span>
</div>
<div class="message my-message">
Actually everything was fine. I'm very excited to show this to our team.
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:31 AM, Today</span>
</div>
<i class="fa fa-circle online"></i>
<i class="fa fa-circle online" style="color: #AED2A6"></i>
<i class="fa fa-circle online" style="color:#DAE9DA"></i>
</li>
</ul>
</div> <!-- end chat-history -->
<div class="chat-message clearfix">
<textarea name="message-to-send" id="message-to-send" placeholder ="Type your message" rows="3"></textarea>
<i class="fa fa-file-o"></i>
<i class="fa fa-file-image-o"></i>
<button>Send</button>
</div> <!-- end chat-message -->
</div> <!-- end chat -->
</div>
</div>
</div>
</body>
Please check snippet in full page for a better view
Replacing height: 100% with min-height: 100% in selector #chat-canvas will make your chat-canvas cover its child chat-field
* {
margin: 0;
padding: 0;
box-sizing: border-box !important;
}
html, body, #body {
background-color: #ffffff;
font-size: 15px;
color: #565656;
width: 100%;
padding: 0;
margin-left: 0;
margin-right: 0;
font-family: 'roboto', sans-serif;
font-weight: 300;
}
#body, .app html, body {
background-color: #f9f9f9;
font-size: 15px;
color: #565656;
width: 100%;
height: 100%;
padding: 0;
margin-left: 0;
margin-right: 0;
font-family: 'roboto', sans-serif;
font-weight: 300;
min-height: 100%;
}
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
transition: all 3s ease-in-out;
height: 100%;
min-height: 100%;
}
*,*:before,*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#chat-canvas {
width: 94% !important;
min-height: 100%;
position: absolute;
float: left;
display: inline-block;
overflow: hidden;
}
.app-nav {
position: relative;
height: 100%;
width: 6%;
display: inline-block;
}
.tl-menu {
position: absolute;
overflow: hidden;
float: left;
top: 0;
height: 100%;
list-style-type: none;
margin: 0;
padding: 0;
background: #1b1e24;
z-index: 9999;
}
.tl-menu img{
max-height: 80%;
}
.tl-menu li a {
display: block;
height: 5em;
width: 5em;
line-height: 5em;
text-align: center;
color: #999;
position: relative;
border-bottom: 1px solid rgba(104,114,134,0.05);
-webkit-transition: background 0.1s ease-in-out;
-moz-transition: background 0.1s ease-in-out;
transition: background 0.1s ease-in-out;
}
.tl-menu li a:hover,
.tl-menu li:first-child a{
color: #55fec6;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.tl-menu li a:active {
background: #afdefa;
color: #FFF;}
/* class for current item */
.tl-menu li.tl-current a {
background: #343a47;
color: #bbe6fe;
}
.tl-menu li a:before {
font-family: 'entypo', sans-serif;
speak: none;
font-style: normal;
font-weight: normal;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 1.4em;
-webkit-font-smoothing: antialiased;
}
.tl-menu li a.icon-logo:before {
font-weight: 700;
font-size: 300%;
}
/* ---------- CHAT ---------- */
.people-list {
width: 30%;
float: right;
}
.people-list .search {
padding: 20px;
}
.people-list input {
border-radius: 3px;
border: none;
padding: 14px;
color: white;
background: #6A6C75;
width: 90%;
font-size: 14px;
}
.people-list .fa-search {
position: relative;
left: -25px;
}
.people-list ul {
padding: 20px;
height: 770px;
}
.people-list ul li {
padding-bottom: 20px;
}
.people-list img {
float: left;
}
.people-list .about {
float: left;
margin-top: 8px;
}
.people-list .about {
padding-left: 8px;
}
.people-list .status {
color: #92959E;
}
.chat {
width: 70%;
float: left;
position: absolute;
background: #F2F5F8;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
color: #434651;
}
.chat .chat-header {
padding: 20px;
border-bottom: 2px solid white;
}
.chat .chat-header img {
float: left;
}
.chat .chat-header .chat-about {
float: left;
padding-left: 10px;
margin-top: 6px;
}
.chat .chat-header .chat-with {
font-weight: bold;
font-size: 16px;
}
.chat .chat-header .chat-num-messages {
color: #92959E;
}
.chat .chat-header .fa-star {
float: right;
color: #D8DADF;
font-size: 20px;
margin-top: 12px;
}
.chat .chat-history {
padding: 30px 30px 20px;
border-bottom: 2px solid white;
overflow-y: scroll;
height: 575px;
}
.chat .chat-history .message-data {
margin-bottom: 15px;
}
.chat .chat-history .message-data-time {
color: #a8aab1;
padding-left: 6px;
}
.chat .chat-history .message {
color: white;
padding: 18px 20px;
line-height: 26px;
font-size: 16px;
border-radius: 7px;
margin-bottom: 30px;
width: 90%;
position: relative;
}
.chat .chat-history .message:after {
bottom: 100%;
left: 7%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-bottom-color: #86BB71;
border-width: 10px;
margin-left: -10px;
}
.chat .chat-history .my-message {
background: #86BB71;
}
.chat .chat-history .other-message {
background: #94C2ED;
}
.chat .chat-history .other-message:after {
border-bottom-color: #94C2ED;
left: 93%;
}
.chat .chat-message {
padding: 30px;
}
.chat .chat-message textarea {
width: 100%;
border: none;
padding: 10px 20px;
font: 14px/22px "Lato", Arial, sans-serif;
margin-bottom: 10px;
border-radius: 5px;
resize: none;
}
.chat .chat-message .fa-file-o, .chat .chat-message .fa-file-image-o {
font-size: 16px;
color: gray;
cursor: pointer;
}
.chat .chat-message button {
float: right;
color: #94C2ED;
font-size: 16px;
text-transform: uppercase;
border: none;
cursor: pointer;
font-weight: bold;
background: #F2F5F8;
}
.chat .chat-message button:hover {
color: #75b1e8;
}
.online, .offline, .me {
margin-right: 3px;
font-size: 10px;
}
.online {
color: #86BB71;
}
.offline {
color: #E38968;
}
.me {
color: #94C2ED;
}
.align-left {
text-align: left;
}
.align-right {
text-align: right;
}
.float-right {
float: right;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.chat-container {
bottom: 0;
left: 0;
right: 0;
height: auto;
margin: 0 auto;
width: 750px;
background: #444753;
border-radius: 5px;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<body class="app">
<!-- NAV -->
<div class="app-nav">
<ul class="tl-menu">
<li><img src="https://i.imgur.com/ngO5Ohx.png" alt="Mendr Logo" height="50" width="50"></li>
<li><img src="{{user.picture}}"></li>
<li><i class="fa fa-plus" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-wechat" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-map" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-search" style="font-size:30px; margin-top:20px;"></i></li>
<li><i class="fa fa-sign-out" style="font-size:30px; margin-top:20px;"></i></li>
</ul>
</div>
<!-- END NAV -->
<!-- CHAT -->
<div id="chat-canvas">
<div class="clearfix chat-container">
<div class="people-list" id="people-list">
<div class="search">
<input type="text" placeholder="search" />
<i class="fa fa-search"></i>
</div>
<ul class="list">
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01.jpg" alt="avatar" />
<div class="about">
<div class="name">Vincent Porter</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_02.jpg" alt="avatar" />
<div class="about">
<div class="name">Aiden Chavez</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 7 mins ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_03.jpg" alt="avatar" />
<div class="about">
<div class="name">Mike Thomas</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_04.jpg" alt="avatar" />
<div class="about">
<div class="name">Erica Hughes</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_05.jpg" alt="avatar" />
<div class="about">
<div class="name">Ginger Johnston</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_06.jpg" alt="avatar" />
<div class="about">
<div class="name">Tracy Carpenter</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 30 mins ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_07.jpg" alt="avatar" />
<div class="about">
<div class="name">Christian Kelly</div>
<div class="status">
<i class="fa fa-circle offline"></i> left 10 hours ago
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_08.jpg" alt="avatar" />
<div class="about">
<div class="name">Monica Ward</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_09.jpg" alt="avatar" />
<div class="about">
<div class="name">Dean Henry</div>
<div class="status">
<i class="fa fa-circle offline"></i> offline since Oct 28
</div>
</div>
</li>
<li class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_10.jpg" alt="avatar" />
<div class="about">
<div class="name">Peyton Mckinney</div>
<div class="status">
<i class="fa fa-circle online"></i> online
</div>
</div>
</li>
</ul>
</div>
<div class="activity-info">
<div class="chat">
<div class="chat-header clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chat_avatar_01_green.jpg" alt="avatar" />
<div class="chat-about">
<div class="chat-with">Chat with Vincent Porter</div>
<div class="chat-num-messages">already 1 902 messages</div>
</div>
<i class="fa fa-star"></i>
</div> <!-- end chat-header -->
<div class="chat-history">
<ul>
<li class="clearfix">
<div class="message-data align-right">
<span class="message-data-time" >10:10 AM, Today</span>
<span class="message-data-name" >Olia</span> <i class="fa fa-circle me"></i>
</div>
<div class="message other-message float-right">
Hi Vincent, how are you? How is the project coming along?
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:12 AM, Today</span>
</div>
<div class="message my-message">
Are we meeting today? Project has been already finished and I have results to show you.
</div>
</li>
<li class="clearfix">
<div class="message-data align-right">
<span class="message-data-time" >10:14 AM, Today</span>
<span class="message-data-name" >Olia</span> <i class="fa fa-circle me"></i>
</div>
<div class="message other-message float-right">
Well I am not sure. The rest of the team is not here yet. Maybe in an hour or so? Have you faced any problems at the last phase of the project?
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:20 AM, Today</span>
</div>
<div class="message my-message">
Actually everything was fine. I'm very excited to show this to our team.
</div>
</li>
<li>
<div class="message-data">
<span class="message-data-name"><i class="fa fa-circle online"></i> Vincent</span>
<span class="message-data-time">10:31 AM, Today</span>
</div>
<i class="fa fa-circle online"></i>
<i class="fa fa-circle online" style="color: #AED2A6"></i>
<i class="fa fa-circle online" style="color:#DAE9DA"></i>
</li>
</ul>
</div> <!-- end chat-history -->
<div class="chat-message clearfix">
<textarea name="message-to-send" id="message-to-send" placeholder ="Type your message" rows="3"></textarea>
<i class="fa fa-file-o"></i>
<i class="fa fa-file-image-o"></i>
<button>Send</button>
</div> <!-- end chat-message -->
</div> <!-- end chat -->
</div>
</div>
</div>
</body>
You should use calc(%100 - 200px); as a value to the width. Look up calc CSS it will work because I had the same problem.
Here you go: https://www.w3schools.com/cssref/func_calc.asp
I tried to solve your problem. please check https://jsfiddle.net/komal10041992/v5k1Lhgf/4/. I removed overflow property, gave height:auto and width: 100%
I have a horizontal timeline made with list (li) elements that has display:flex; at it's parent attribute. That make the list horizontal. But I want the texts to be maximum two rows in the boxes.
So for example, I want this:
The first
asphalt is
delivered.
To become this:
The first asphalt
is delivered.
I want that to be a rule and the width can become as wide as it need to be.
And I have seen a lot of examples where the solution is to work with overflow:hidden. But that's not what I looking for. I wanna know if there is a way to get a dynamic width so all the text is visible.
Edit:
Here is the snippet:
.left-arrow,.right-arrow {
float:left;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
margin-top:20px;
cursor:pointer;
}
.left-arrow {
border-right:20px solid black;
padding-left: 5px;
}
.right-arrow {
border-left:20px solid black;
padding-right: 5px;
}
.timeline {
list-style-type: none;
display: flex;
justify-content: left;
margin: 0 5px;
padding: 0;
float: left;
width: calc(100% - 60px);
overflow-x: scroll;
vertical-align: top;
}
.timeline li {
width: 300px;
vertical-align: top;
}
.timeline li a {
color: #000;
}
.timestamp {
margin-bottom: 10px;
padding: 10px 10px 0;
display: flex;
flex-direction: column;
align-items: center;
white-space: nowrap;
font-weight: 600;
}
.status {
padding: 10px 5px 10px;
display: flex;
justify-content: center;
border-top: 3px solid #000;
position: relative;
font-size: 1.1rem;
}
.status:before {
content: "";
width: 4px;
height: 8px;
background-color: black;
position: absolute;
top: -10px;
left: calc(50% - (4px / 2));
}
<ul class="timeline" id="timeline">
<li>
<a href="#pop-1910-20">
<div class="timestamp">1910-20</div>
<div class="status">The founder buys land.</div>
</a>
</li>
<li>
<a href="#pop-1928">
<div class="timestamp">1928</div>
<div class="status">The refinery goes into operation.</div>
</a>
</li>
<li>
<a href="#pop-1929">
<div class="timestamp">1929</div>
<div class="status">The first asphalt is delivered.</div>
</a>
</li>
<li>
<a href="#pop-1931">
<div class="timestamp">1931</div>
<div class="status">New cracker.</div>
</a>
</li>
<li>
<a href="#pop-1939-45">
<div class="timestamp">1939-45</div>
<div class="status">Central role for the national sales</div>
</a>
</li>
<li>
<a href="#pop-1950s">
<div class="timestamp">1950-talet</div>
<div class="status">The network of petrol stations is being expanded</div>
</a>
</li>
<li>
<a href="#pop-1956">
<div class="timestamp">1956</div>
<div class="status">The second refinery is finished</div>
</a>
</li>
<li>
<a href="#pop-1958">
<div class="timestamp">1958</div>
<div class="status">The founder dies.</div>
</a>
</li>
<li>
<a href="#pop-1960">
<div class="timestamp">1960</div>
<div class="status">Risky sales strategy</div>
</a>
</li>
<li>
<a href="#pop-1967-69">
<div class="timestamp">1967-69</div>
<div class="status">Increased capacity of bitumen</div>
</a>
</li>
<li>
<a href="#pop-1974">
<div class="timestamp">1974</div>
<div class="status">The energy crisis leads to financial crisis</div>
</a>
</li>
</ul>
We can also fix the two lines for li elements by fixing the height and and line-height by halve of it. So two lines only can come but width can be maximum. So that there will be two lines but it would expand on x side. It will be something like this link below.
.twolines{
height: 50px;
line-height: 25px;
width: 100%;
overflow-y: hidden;
}
<ul>
<li class="twolines">Hello World. If it has two lines but have max width it can to be produced so that it will not expanded. Some extra text will be truncated when even two lines exceeded</li>
<li class="twolines">Hello World. If it has two lines but have max width it can to be produced so that it will not expanded.</li>
</ul>
Taken your code snippet and used the same logic of height and line-height. Along with that used box-sizing border box as there was some alignment (like padding and boader) so the width will be controlled including those also.Now only two lines and taken width accrodingly.
.left-arrow,.right-arrow {
float:left;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
margin-top:20px;
cursor:pointer;
}
.left-arrow {
border-right:20px solid black;
padding-left: 5px;
}
.right-arrow {
border-left:20px solid black;
padding-right: 5px;
}
.timeline {
list-style-type: none;
display: flex;
justify-content: left;
margin: 0 5px;
padding: 0;
float: left;
width: calc(100% - 60px);
overflow-x: scroll;
vertical-align: top;
}
.timeline li {
width: 300px;
vertical-align: top;
}
.timeline li a {
color: #000;
}
.timestamp {
margin-bottom: 10px;
padding: 10px 10px 0;
display: flex;
flex-direction: column;
align-items: center;
white-space: nowrap;
font-weight: 600;
}
.status {
padding: 10px 5px 10px;
display: flex;
justify-content: center;
border-top: 3px solid #000;
position: relative;
font-size: 1.1rem;
box-sizing: border-box;
height: 43px;
line-height: 15px;
width: 213px;
}
.status:before {
content: "";
width: 4px;
height: 8px;
background-color: black;
position: absolute;
top: -10px;
left: calc(50% - (4px / 2));
}
<ul class="timeline" id="timeline">
<li>
<a href="#pop-1910-20">
<div class="timestamp">1910-20</div>
<div class="status">The founder buys land.</div>
</a>
</li>
<li>
<a href="#pop-1928">
<div class="timestamp">1928</div>
<div class="status">The refinery goes into operation.</div>
</a>
</li>
<li>
<a href="#pop-1929">
<div class="timestamp">1929</div>
<div class="status">The first asphalt is delivered.</div>
</a>
</li>
<li>
<a href="#pop-1931">
<div class="timestamp">1931</div>
<div class="status">New cracker.</div>
</a>
</li>
<li>
<a href="#pop-1939-45">
<div class="timestamp">1939-45</div>
<div class="status">Central role for the national sales</div>
</a>
</li>
<li>
<a href="#pop-1950s">
<div class="timestamp">1950-talet</div>
<div class="status">The network of petrol stations is being expanded</div>
</a>
</li>
<li>
<a href="#pop-1956">
<div class="timestamp">1956</div>
<div class="status">The second refinery is finished</div>
</a>
</li>
<li>
<a href="#pop-1958">
<div class="timestamp">1958</div>
<div class="status">The founder dies.</div>
</a>
</li>
<li>
<a href="#pop-1960">
<div class="timestamp">1960</div>
<div class="status">Risky sales strategy</div>
</a>
</li>
<li>
<a href="#pop-1967-69">
<div class="timestamp">1967-69</div>
<div class="status">Increased capacity of bitumen</div>
</a>
</li>
<li>
<a href="#pop-1974">
<div class="timestamp">1974</div>
<div class="status">The energy crisis leads to financial crisis</div>
</a>
</li>
</ul>