I have this code: https://codepen.io/anon/pen/QdQEQW
As you can see, if you hover over "Dropdown" it also changes the background color of "V", the :after part. I do not want that. Simple. But I just can't get it done. I've googled and tried and tried but I just cant figure out how.
I've tried a bunch of different, variations, eg
.onclick-menu:hover.onclick-menu:after {
background: blue;
}
.onclick-menu:after:hover {
background: blue;
}
.onclick-menu:hover > onclick-menu:after:hover {
background: blue;
}
.onclick-menu:hover + onclick-menu:hover:after {
background: blue;
}
It seems to me that you want the following:
#top {
background: black;
line-height: 39px;
}
#top nav a {
color: #21262F;
padding: 10px 15px;
background: green;
}
#top nav a:hover {
background: red;
}
.onclick-menu {
position: relative;
display: inline-block;
}
.onclick-menu:after {
content: "V";
background: green;
margin-left: -4px;
padding: 8px 10px;
}
.onclick-menu:hover:after {
background: green;
}
.onclick-menu:focus {
outline: none;
pointer-events: none;
}
.onclick-menu:focus .onclick-menu-content {
opacity: 1;
visibility: visible;
pointer-events: auto;
}
.onclick-menu-content {
position: absolute;
z-index: 1;
background: #F4F4F4;
opacity: 0;
visibility: hidden;
transition: visibility 0.5s;
}
<div id="top">
<nav>
Hey
<div tabindex="0" class="onclick-menu">
Dropdown
<ul class="onclick-menu-content">
<li>Look, mom</li>
<li>no JavaScript!/li>
<li>Pretty nice, right?</li>
</ul>
</div>
Support
</nav>
</div>
For clarity's sake, this is the one:
.onclick-menu:hover:after {
background: green;
}
I don't understand why you added .onclick-menu twice in that selector in the first place. It's the pseudo element of the same item, so you don't need to repeat the parent.
Related
I am pretty new to css. I have defined a dot element with different collors.
/*Dots*/
.ccrdot {
display: inline-block;
position: absolute;
background-color: #8d8d8d;
border-radius: 50%;
opacity: 0.5;
width: 10px;
height: 10px;
pointer-events: none;
}
.ccrdot.red {
background-color: #FF0000;
}
.ccrdot.yellow {
background-color: #fffb09;
}
.ccrdot.green {
background-color: #67ff09;
}
But when i use this like:
> <span class="ccrdot"></span><span>Text Text Text</span>
<span class="ccrdot"></span> Text Text
or
<div class="ccrdot"></div> Text Text
The text slides under the dot element. I want to present them side by side. What did i do wrong?
Thank you.
position: absolute takes them out of the text flow, so there's no space reserved for them anymore, if you remove it they'll have their own space.
/*Dots*/
.ccrdot {
display: inline-block;
background-color: #8d8d8d;
border-radius: 50%;
opacity: 0.5;
width: 10px;
height: 10px;
pointer-events: none;
}
.ccrdot.red {
background-color: #FF0000;
}
.ccrdot.yellow {
background-color: #fffb09;
}
.ccrdot.green {
background-color: #67ff09;
}
I need to make dropdown menu with connected area without border between button and dropdown-panel, but the borders at the edges of dropdown panel will be preserved. I use dropdown-pane from Foundation 6.
This is my result:
And this is my target:
Below is my HTML code where dropdown-wrapper is container for dropdown toggler and dropdown-panel. data-v-offset is set -1 to overlap border of item-container. I tried to set up the bottom border of item-container to background color, but dropdown-pane instantly overlap the item-container element.
<ul class="bottom-menu">
<li class="dropdown-wrapper" data-toggle="header-shopping-card" >
<a href="#" class="item-container">
<div class="item-content">
<div class="item-title">
<span>Nákupní košík</span>
<span class="box primary"><span>4</span></span>
</div>
<div class="item-subtitle">12 000 Kč</div>
</div>
</a>
<div
class="dropdown-pane"
id="header-shopping-card"
data-dropdown data-hover="true"
data-hover-pane="false"
data-position="bottom"
data-alignment="right"
data-hover-delay=0
data-v-offset=-1
>
Just some junk that needs to be said. Or not. Your choice.
</div>
</li>
</ul>
And this is my SCSS code:
.bottom-menu {
#include menu-base;
#include flex-align(right, middle);
.dropdown-wrapper {
border: 0;
&:hover {
.item-container {
background-color: $light-gray;
border: 1px solid $dark-gray;
border-bottom: 1px solid transparent;
.item-content {
color: $black;
}
.item-subtitle {
color: $dark-gray;
}
}
}
.dropdown-pane {
background-color: $light-gray;
border: 1px solid $dark-gray;
}
}
.dropdown-pane {
font-size: $global-font-size;
}
.item-container {
transition-delay: 0;
display: flex;
align-items: flex-end;
font-size: $small-font-size;
border: 1px solid transparent;
.item-icon {
width: rem-calc(35px);
height: auto;
color: $accent-secondary;
.item-icon-path {
fill: $accent-secondary;
}
.item-icon-path-circle {
fill: $green;
}
.item-icon-path-check {
fill: $header-primary-color;
}
}
.item-content {
padding-left: 6px;
color: $header-primary-color;
font-size: rem-calc(12px);
.item-title {
margin-bottom: 4px;
}
.item-subtitle {
line-height: 1em;
color: $header-secondary-color;
}
.box {
display: inline-flex;
justify-content: center;
align-items: center;
min-width: rem-calc(21px);
min-height: rem-calc(21px);
color: $white;
font-size: rem-calc(13px);
}
.box.primary {
background-color: $primary-color;
}
}
}
}
}
}
}
I don't know hot to remove border between dropdown-pane and item-container. Can you please help me? I'll be glad for every help.
Thank you,
Michal
.item-container must have position: relative and .dropdown-pane must have position: absolute. After that the z-index is working. Then Bottom border of the .item-container is overlapped by:
.item-container:after {
content: '';
background-color: $light-gray;
position: absolute;
width: 100%;
height: 1px;
left: 0;
bottom: -1px;
}
I'm having issues with my CSS positioning for a conversation/chat page. Please see the code in this fiddle for my first attempt: https://jsfiddle.net/1gsykwL5/
Is there any way to make the div containing the 'logo' 100% height, so that the text (message) doesn't wrap underneath it? I've played around with position: absolute but it really screws up alignment.
I think there's probably a better way of coding it to be honest. But I'm not sure how. Can anybody please advise?
Thanks!
PS - code which includes the padding fix by Rick Jelier:
body{
font-family:arial;
}
.newchat {
padding: 10px;
}
.newdiv1 {
width: 50px;
height:100%;
float: left;
margin: 0px 10px 10px 0px;
}
.chat2 ul{
list-style: none;
padding:0px;
}
.chat2 ul li
{
border-radius: 5px;
}
.chat2 ul li:hover .thumbnail {
background: #bd6982;
}
.chat2 ul li .thumbnail {
display: inline-block;
background: #bfbfbf;
width: 50px;
color: #ffffff;
line-height: 50px;
text-align: center;
text-decoration: none;
-webkit-transition: background 0.3s linear 0s;
-moz-transition: background 0.3s linear 0s;
-ms-transition: background 0.3s linear 0s;
-o-transition: background 0.3s linear 0s;
transition: background 0.3s linear 0s;
border-radius: 50%;
}
.chat2 ul li:nth-child(2n) {
background: #f2f2f2;
}
.newdiv2 .meta {
color: #b3b3b3;
font-size: 12px;
padding-left: 60px;
}
.newdiv2 .meta a:hover {
text-decoration: underline;
}
.newdiv2 .meta a {
color: #999999;
text-decoration: none;
}
.newdiv2 h3 {
font-size:14px;
display: block;
width: 100%;
margin: 0px 0px 5px 0px;
color: #808080;
}
.newdiv2
{
font-size:12px;
color: #cccccc;
}
.newdiv2 .preview
{
display:block;
margin-bottom: 5px;
padding-left: 60px;
}
.otherUser
{
margin-left:30px;
}
<div class="chat2">
<ul>
<li>
<div class="newchat">
<div class="newdiv2">
<div class="newdiv1">
<a class="thumbnail" href="#">KS</a>
</div>
<h3>Kenny Sing</h3>
<span class="preview">make sure you take a look at the... ashiud hiuas hdiu huio hiu hiuo hiu hiu hio uhoiu hoi hui hoiouh
idsh ifu hisuod hfoiu hidsu hiu fhiuo dshiu hiuo hiou hiu hoiuhiohiuo hiu ohi uhiou hi ouhi iusdh fius dhuif hsdiuf hisdu fhusid f2f2f2 siudphf uisd h
osih doifh sidoh fiusd hiuf hdsiu hiu hiu</span>
<div class="meta">3h ago · Category · Reply</div>
</div>
</div>
</li>
<li class="otherUser">
<div class="newchat">
<div class="newdiv2">
<div class="newdiv1">
<a class="thumbnail" href="#">KS</a>
</div>
<h3>Kenny Sing</h3>
<span class="preview">make sure you take a look at the... ashiud hiuas hdiu huio hiu hiuo hiu hiu hio uhoiu hoi hui hoiouh
idsh ifu hisuod hfoiu hidsu hiu fhiuo dshiu hiuo hiou hiu hoiuhiohiuo hiu ohi uhiou hi ouhi</span>
<div class="meta">3h ago · Category · Reply</div>
</div>
</div>
</li>
</ul>
</div>
Try adding 60px of padding to the left of the textbox itself:
.newdiv2 .preview {
/* current css */
padding-left: 60px;
}
I tried it in the jsfiddle and it seems to work.
Hope this helps!
I see it in two ways:
position absolute of logo (+ top:10px, left:10px), and padding left + position relative to the container - with padding it shouldn't screw up your your alignment
or
Padding to the message container and negative margin to the logo
.newchat {
padding-left: 70px;
}
.newdiv1 {
margin: 0px 10px 10px -60px;
}
Less code more fun
Since you asked for leaner markup, this is how I'd approach it:
body {
background-color: #333;
}
.chat {
list-style-type: none;
}
.meta-message {
display: block;
color: #999;
margin-top: 5px;
}
.sender-message,
.reply-message {
background-color: #fff;
border-radius: 15px;
display: block;
font-family: sans-serif;
font-size: 20px;
line-height: 1.25;
max-width: 400px;
margin-bottom: 15px;
min-height: 60px;
padding: 15px 15px 15px 80px;
position: relative;
}
.sender-message::before,
.reply-message::before {
content: attr(data-shortname);
display: inline-block;
width: 50px;
height: 50px;
line-height: 50px;
position: absolute;
left: 15px;
top: 15px;
background-color: #a00;
text-align: center;
border-radius: 50%;
color: #fff;
}
.sender-message .name,
.reply-message .name {
color: #a00;
font-size: 28px;
margin: 0;
text-align: right;
}
.reply-message {
background-color: #eee;
margin-left: 80px;
}
.reply-message .name {
color: #0a0;
}
.reply-message::before {
background-color: #0a0;
}
<ol class="chat">
<li class="sender-message" data-shortname="kk">
<h3 class="name">Kenny King</h3>Is there any way to make the div containing the 'logo' 100% height, so that the text (message) doesn't wrap underneath it? I've played around with position: absolute but it really screws up alignment.<span class="meta-message">2016/12/13 12:41 p.m.</span>
</li>
<li class="reply-message" data-shortname="cw">
<h3 class="name">connexo websolutions</h3>Let's see how far we can get from a small codepen snippet...<span class="meta-message">2016/12/13 12:42 p.m.</span>
</li>
</ol>
https://codepen.io/connexo/pen/eBPXbd
Why did I use an ol?
Because a chat consists of a (typically chronologically) ordered list of messages (where order does matter).
I think you will be able to start from here and get to where you want to go.
My question is actually more complex then the title, but I couldn't come up with a better one.
Initial Setup:
I use Bootstrap v4.0.0-alpha.2 and I ripped out this simple sidebar. I'm not sure why and if it's relevant but I also set flex: true in my _library-variable-overrides.scss (I use css-burrito) but since I only set it to try it out, I'm probably okay with turning it off. ;-)
What I want to do:
I would like to have a button in the sidebar that is bottom aligned. Ideally it's centered horizontally in the sidebar and has about 1em margin to the bottom.
What my code looks like:
_shell.scss & _sidenav.scss:
#shell-wrapper {
padding-left: 0;
transition: all 0.5s ease;
}
#shell-wrapper.toggled {
padding-left: 250px;
#shell-content-wrapper {
position: absolute;
margin-right: -250px;
}
}
#media(min-width:768px) {
#shell-wrapper {
padding-left: 250px;
}
#shell-wrapper.toggled {
padding-left: 0;
#shell-content-wrapper {
position: relative;
margin-right: 0;
}
}
#shell-content-wrapper {
padding: 20px;
position: relative;
}
}
#sidenav-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
transition: all 0.5s ease;
}
#shell-wrapper.toggled {
#sidenav-wrapper {
width: 250px;
}
}
#shell-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}
/* Sidenav Styles */
.sidenav-nav {
position: absolute;
top: 0;
width: 250px;
margin: 0;
padding: 0;
list-style: none;
li {
text-indent: 20px;
line-height: 40px;
a {
display: block;
text-decoration: none;
color: #999999;
}
a:hover {
text-decoration: none;
color: #fff;
background: rgba(255, 255, 255, 0.2);
}
a:active, a:focus {
text-decoration: none;
}
}
>.sidenav-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
a {
color: #999999;
}
a:hover {
color: #fff;
background: none;
}
}
}
#media(min-width:768px) {
#sidenav-wrapper {
width: 250px;
}
#shell-wrapper.toggled #sidenav-wrapper {
width: 0;
}
}
and index.html:
<div id="shell-wrapper" class="toggled">
<div id="sidenav-wrapper">
<ul class="sidenav-nav">
<li class="sidenav-brand">
Brand
</li>
<li>
Item 1
</li>
<li>
Item 2
</li>
<li id="logout">
<button class="btn btn-danger-outline">Logout</button>
</li>
</ul>
</div>
<button class="navbar-toggler" type="button">
☰
</button>
<div id="shell-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<!--Main Content Here-->
</div>
</div>
</div>
</div>
</div>
The logout button is one in question. I just tried doing it as a <li> of the sidenav-nav but I'm not tied to this setup.
What I have tried so far:
a lot!
What came closest to what I want was adding this:
.sidenav-nav {
height: 100%;
}
#logout {
position: absolute;
bottom: 1em;
}
It's pretty close to my goal on a desktop browser, but hitting that show me this on a phone button in chrome, the logout button is just gone.
i haven't worked with css-buritto, but you could look into giving the button a class or id and passing the position:relative argument you can then set a bottom: 1em and that should position the button at the bottom. alternativly you can also look into the other position elements like fixed that could also do the trick
like you mentioned a the end
#logout {
position: relative;
bottom: 1em;
}
I am creating a simple menu in CSS. The only "trick" is that I'd like diagonal left and right borders.
That's not really a problem though. Problem is that I need the first item of the menu to get a regular vertical border instead of a diagonal one.
<nav>
<ul>
<li><span>Home</span></li>
<li><span>Tutorials</span></li>
<li><span>Snippets</span></li>
<li><span>Articles</span></li>
<li><span>Resources</span></li>
<li><span>Contact</span></li>
</ul>
</nav>
and the CSS:
nav ul {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
nav li {
display: inline-block;
margin: 0 5px;
transition: all 0.3s;
}
nav a {
display: block;
color: #285064;
transition: all 0.3s;
}
nav a:hover {
color: #12242d;
}
nav span {
display: block;
}
#media all and (min-width: 690px) {
nav li {
margin: 0;
transform: skewX(-10deg);
}
nav a {
padding: 10px 20px;
color: #fff;
background-color: #285064;
}
nav a:hover {
color: #fff;
background-color: #12242d;
}
nav span {
transform: skewX(10deg);
}
}
Here is a JsFiddle of the current menu:
http://jsfiddle.net/mfL8509t/
Basically on that example, I'd need the "home" container to get a vertical regular border on the left hand side only.
How could I do that?
Thanks a lot!
Very easy, use first-child of
nav li:first-child {
transform: inherit;
}