I want my priority-menu (the one with 2 dots) to have the 3 dots displayed horizontally. Since each individual dot is inline-block I don't understand why they are stacked on top of one another. The menu is rendered by clicking on the blue circle on the right of the "save task" button, which changes its display to inline instead of none. I tried changing that to inline-block and nothing seems to have changed.
/* The popup menu - hidden by default */
#priority-menu {
display: none;
position: absolute;
top: 150%;
border: 3px solid #f1f1f1;
z-index: 9;
max-width: 300px;
padding: 10px;
background-color: white;
}
#priority-dot-open-menu {
position: relative;
height: 25px;
width: 25px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
cursor: pointer;
}
#priority-dot-open-menu:hover {
opacity: 1;
}
#priority-dot-blue {
height: 25px;
width: 25px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
#priority-dot-yellow {
height: 25px;
width: 25px;
background-color: yellow;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
#priority-dot-red {
height: 25px;
width: 25px;
background-color: red;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
.modal-footer {
padding: 0;
}
#priority-menu::after {
content: " ";
position: absolute;
bottom: 100%; /* At the top of the tooltip */
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
<div class="modal-footer d-flex flex-row justify-content-start pl-0 mt-4 border-0">
<button type="button" class="btn btn-primary btn-sm" id="add-task-modal-save">Save task</button>
<span id="priority-dot-open-menu">
<span id="priority-menu">
<span class="tooltip-top"></span>
<span id="priority-dot-blue"></span>
<span id="priority-dot-yellow"></span>
<span id="priority-dot-red"></span>
</span>
</span>
</div>
Your priority-menu is contained within an element which you’ve set to 25px width. Try removing this and changing to 300px, like your priority-menu.
#priority-dot-open-menu {
position: relative;
height: 25px
width: 300px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
cursor: pointer;
}
You can also try adding a declared width to your menu instead of just a max-width.
#priority-menu {
width:300px;
}
Related
I need to achieve this button.
Here is my code so far:
.button {
border-color: red;
border-radius: 8px
}
.button::after {
content: '';
background-color: red;
display: block;
width: inherit;
height: 3px;
}
<button class="button">Click me </button>
The problem is that the width covers 100% of the screen, and I need the width of the button; I can't give a specific width to this button because it will receive dynamic text.
You just need to wrap the button in a div with display: inline-block to prevent it going full-width and relative positioning so it can contain an absolutely positioned element inside and from the looks of your image some padding on that element as well to create some space between the button and the line below. Then make your :after pseudo element absolutely positioned and give it width: 100%.
div {
position: relative;
padding: .75rem .5rem;
box-sizing: border-box;
display: inline-block
}
button {
background: transparent;
border-radius: .5rem;
border: 3px solid #EF544F;
padding: .5rem;
color: #EF544F;
font-weight: 600;
font-size: 1.2rem
}
button::after {
content: '';
background-color: #EF544F;
display: block;
position: absolute;
width: inherit;
height: 4px;
width: 100%;
bottom: 0;
left: 0;
border-radius: 999px;
}
<div>
<button>Click me</button>
</div>
This seems to be like on picture:
.button
{
border-radius: 0.5em;
padding: 0.4em 0.8em 0.2em 0.8em;
color: red;
font-weight: bold;
border: 2px solid red;
background-color: transparent;
}
.button::after
{
content: '';
background-color:red;
display: block;
height: 3px;
position: relative;
left: -1.3em;
bottom: -1em;
width: calc(100% + 2.6em);
}
<button class="button">Tab Tile</button>
you can try min-width
.button::after{
content: '';
background-color:red;
display: inline-block;
width: auto;
height: 3px;
min-width:100px;
}
When I hover over the first Div, the tooltip is shown further away than if I hover over the following two divs. Obviously it is because the text inside the div is larger/longer. But I don't want to show the tooltip span not depending on the hover text, but relating to the containing div of the text, so it is shown always at the same position.
jQuery is not an option for anything though but I kind of think, that it's a CSS problem anyway.
.subPhaseContainer {
float: left;
margin: 0 auto;
}
.projectItem {
margin: 4px;
border: 2px solid black;
cursor: pointer;
height: 17px;
}
.projectItem.green {
background-color: green;
color: white;
}
.projectNumber {
position: relative;
display: inline-block;
width: 80px;
}
.projectNumber .tooltiptext {
visibility: hidden;
width: fit-content;
text-align: left;
padding: 5px;
top: -1px;
position: absolute;
z-index: 1;
margin-left: 34px;
transition: opacity 0.3s;
border: 1px solid black;
}
.projectNumber .tooltiptext::after {
content: "";
position: absolute;
top: 20%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
.projectNumber:hover .tooltiptext.green {
background-color: green;
color: white;
visibility: visible;
opacity: 1;
}
.projectNumber:hover .tooltiptext.yellow {
background-color: yellow;
visibility: visible;
opacity: 1;
}
.projectNumber:hover .tooltiptext.red {
background-color: red;
color: white;
visibility: visible;
opacity: 1;
}
<div class="subPhaseContainer">
<div class="projectItem green">
<div class="projectNumber"><span>AAAA-00</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
<div class="projectItem green">
<div class="projectNumber">
<span>BBB-11</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
<div class="projectItem green">
<div class="projectNumber">
<span>CCC-22</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
</div>
You need to specify either a 'left' or 'right' position for your tooltiptext span, otherwise its left/right position will be the same as it would have been had you kept the tooltiptext span positioned relative.
So just update your CSS for the tooltiptext to this:
.projectNumber .tooltiptext {
visibility: hidden;
width: fit-content;
text-align: left;
padding: 5px;
top: -1px;
right: -100%;
position: absolute;
z-index: 1;
margin-left: 34px;
transition: opacity 0.3s;
border: 1px solid black;
}
Need to make a hamburger item with each line shorter than the last.
E.g.
------
-----
----
My idea is just to have a div with 3 spans inside it.
<label for="menu_collapse_icon" class="menu_collapse_icon_label">
<span class="menu_bar"></span>
<span class="menu_bar"></span>
<span class="menu_bar"></span>
</label>
And then in the CSS do e.g:
.menu_collapse_icon {
FOR EACH SPAN, REDUCE ITS LENGTH BY X AMOUNT?
}
But I don't know how to do this? I could just create 3 separate length bars, but would rather do it this way.
Add each element inside each other to create cascade:
.menu_bar {
padding-top: 10px;
width: 80%;
display: inline-block;
border-top: 1px solid #454545;
box-sizing: border-box;
}
.menu_collapse_icon_label {
width: 40px;
display: inline-block;
text-align: right;
font-size: 0;
border: 1px solid #ddd;
border-radius: 3px;
padding: 10px 10px 0 0;
}
<label for="menu_collapse_icon" class="menu_collapse_icon_label">
<div class="menu_bar">
<div class="menu_bar">
<div class="menu_bar"></div>
</div>
</div>
</label>
With the markup that you plan to have, this is not possible with a single selector. And am sure you will find many examples if you search.
However, am presenting this just for the sake of getting it done with a single selector. You will need nested elements for this.
label {
display: block; text-align: right;
border: 1px solid #bbb;
width: 32px; height: 32px;
padding: 4px 8px 4px 0px;
}
label span {
display: block; float: right; position: relative;
width: 75%; right: 0px; top: 8px;
border-bottom: 2px solid #999;
}
label > span { margin-top: -4px; }
<label for="menu_collapse_icon" class="menu_collapse_icon_label">
<span class="menu_bar">
<span class="menu_bar">
<span class="menu_bar"></span>
</span>
</span>
</label>
I suppose you could do something like below. You could probably make it responsive if you use percentages for i and the pseudo elements.
label {
display: block;
border: 1px solid #ccc;
width: 48px;
height: 48px;
position: relative;
}
i {
display: block;
background: #999;
height: 2px;
width: 50%;
position: absolute;
top: 50%;
margin-top: -1px;
right: 4px;
}
i::before, i::after {
right: 0;
position: absolute;
height: 2px;
background: #999;
content: "";
}
i::before {
width: 120%;
top: -8px;
}
i::after {
width: 80%;
bottom: -8px;
}
<label for="menu_collapse_icon" class="menu_collapse_icon_label">
<i class="menu-icon"></i>
</label>
However, I discourage it. You'd be better of creating an (SVG) icon that looks like this, and use it inline.
I managed to make it responsive, as a quick bit of fun. However, I do encourage you to look into icons. Here's the link to the responsive show case.
Important CSS:
i {
display: block;
background: #999;
height: 4%;
width: 50%;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 12%;
}
i::before, i::after {
right: 0;
position: absolute;
height: 100%;
background: #999;
content: "";
}
i::before {
width: 125%;
top: -400%;
}
i::after {
width: 75%;
bottom: -400%;
}
I have an application where a user can upload images and delete it by clicking a button on the top right of its thumbnail as shown below
Picture (1)
However, currently my buttons look like this
Picture (2)
I want my buttons to not be located next to the pictures as shown in Picture (2) but to look like Picture (1) and stay that way even as I change the size of the window.
My current css
#media (max-width: 768px) {
.delete {
cursor: pointer !important;
font-size: 30px;
position: absolute;
color: white;
border: none;
background: none;
right: 18px;
top: -9px;
line-height: 1;
}
.delete span {
height: 30px;
width:30px;
background-color: black;
border-radius: 50%;
display: block;
}
}
.model-thumbs img {
margin-left: auto;
margin-right: auto;
cursor: pointer;
box-shadow: 0 0 5px 2px rgba(0,0,0,.15);
}
My current html
<div class="col-xs-6 col-sm-4 col-md-4 col-lg-3 model-thumbs" ng-repeat="model in models track by $index" ng-animate="'animate'">
<button type="button" class="delete" ng-click="deleteModel(model)">
<span>×</span>
<span class="sr-only">Delete</span>
</button>
<img ng-click="selectModel(model)" src="{{model.thumbSrc}}" class="img-responsive" data-toggle="modal" data-target="#detailModal">
</div>
As you can see currently I am trying to utilize the #media tag however when I resize the window it moves from Picture (2) to this picture below
to Picture (1) in a flow motion, meaning, it does not stay put right on the top-right corner of the thumbnails. How can I fix this?
Demo ... Source
HTML
<div class="box">
<button type="button" class="delete" ng-click="deleteModel(model)">
<span>×</span>
</button>
<div class="image">
<img ng-click="selectModel(model)" src="http://nemo-crack.org/uploads/posts/2014-04/1398165049_adobe-410x400.png" />
</div>
</div>
CSS
.delete {
cursor: pointer !important;
font-size: 30px;
position: absolute;
color: white;
border: none;
background: none;
right: -15px;
top: -15px;
line-height: 1;
z-index: 99;
padding: 0;
}
.delete span {
height: 30px;
width: 30px;
background-color: black;
border-radius: 50%;
display: block;
}
.box{
width: calc((100% - 30px) * 0.333);
margin: 5px;
height: 250px;
background: #CCCCCC;
float: left;
box-sizing: border-box;
position: relative;
box-shadow: 0 0 5px 2px rgba(0,0,0,.15);
}
.box:hover{
box-shadow: 0 0 15px 3px rgba(0, 0, 0, 0.5);
}
.box .image{
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.box .image img{
width: 100%;
min-height: 100%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
}
#media (max-width: 600px) {
.box{
width: calc((100% - 20px) * 0.5);
height: 200px;
}
}
Hope this will help you ..
I'm creating my own version of Twitter Bootstrap radio buttons purely based on CSS. The visual feedback for selected radio button is based on input[type="radio"]:checked + span.
As the content of my "buttons" can vary, the width is dynamic. This causes problem aligning the button next to each other.
In my JSfiddle I've set fixed width of 50px. Removing this and the buttons are on top of each other.
Can anyone point me in the right direction of how I can accomplish this?
Here is my code:
//HTML
<div class="button-group binary" data-toggle="buttons-radio">
<div class="radio-wrapper">
<input type="radio" class="active" name="status" value="1" />
<span class="background">Yes</span>
</div>
<div class="radio-wrapper">
<input type="radio" class="inactive" name="status" value="0" checked="checked" />
<span class="background">No</span>
</div>
</div>
//CSS
.button-group{
/*display: table;*/
display: block;
}
.radio-wrapper {
/*display: table-cell; */
display: inline-block;
position: relative;
height: 28px;
margin: 0;
width: 50px; /* I want this to be dynamic */
}
.radio-wrapper:first-child .background{
border-right: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.radio-wrapper:last-child .background{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
input[type="radio"]{
position: absolute;
display: block;
height: 28px;
width: 100%;
z-index: 200;
cursor: pointer;
opacity: 0;
}
input[type="radio"]:checked + span {
background-color: #63B1DE;
color: #fff;
}
.background {
position: absolute;
z-index: 100;
height: 100%;
padding: 0 5px;
border: solid 1px #87A2B2;
background-color: #fff;
text-align: center;
line-height: 28px;
text-transform: uppercase;
}
If you remove position: absolute from you background class, you will no longer need the width style:
jsFiddle
.button-group{
/*display: table;*/
display: block;
}
.radio-wrapper {
/*display: table-cell; */
display: inline-block;
position: relative;
height: 28px;
margin: 0;
/*width: 50px; not needed*/
}
.radio-wrapper:first-child .background{
border-right: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.radio-wrapper:last-child .background{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
input[type="radio"]{
position: absolute;
display: block;
height: 28px;
width: 100%;
z-index: 200;
cursor: pointer;
opacity: 0;
}
input[type="radio"]:checked + span {
background-color: #63B1DE;
color: #fff;
}
.background {
z-index: 100;
height: 100%;
padding: 0 5px;
border: solid 1px #87A2B2;
background-color: #fff;
text-align: center;
line-height: 28px;
text-transform: uppercase;
}
Having a look at your CSS, I think the issue you are having is because you are making the .background position: absolute it is not taking up any space in its parent, so the parent doesn't really have any width, this is why you have to manually set it. Stripping out the absolute positioning for the .background and actually making it an element that takes up space will give the parent a width (which will be based on its content). Now as far as correcting the on top of each other issue, I would think some floating here would work. CSS is here (I also removed some unnecessary rules)
.radio-wrapper {
position: relative;
float:left;
}
.radio-wrapper:first-child .background{
border-right: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.radio-wrapper:last-child .background{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
input[type="radio"]{
position: absolute;
display: block;
height: 28px;
width: 100%;
z-index: 200;
cursor: pointer;
opacity: 0;
}
input[type="radio"]:checked + span {
background-color: #63B1DE;
color: #fff;
}
.background {
height: 100%;
padding: .5em;
border: solid 1px #87A2B2;
background-color: #fff;
text-align: center;
line-height: 28px;
text-transform: uppercase;
}
As per example fiddle.
I did add a bit more padding that you had though so please feel free to adjust as required. I also like padding in ems so if your font changes in size the padding is always relative.