How would I use ::after to make an arrow on my button? - html

I can create a button with an arrow on the right side like this:
.next-button {
font-family: 'Source Sans Pro', Arial, Helvetica, sans-serif;
text-decoration: none;
color: #fff;
text-align: center;
border: none;
background-color: #2399e5;
display: inline-block;
height: 36px;
line-height: 36px;
padding: 0 1rem;
}
.next-point{
vertical-align: top;
width: 0;
height: 0;
display: inline-block;
border-top: 18px solid transparent;
border-bottom: 18px solid transparent;
border-left: 18px solid #2399e5;
border-right: 18px solid transparent;
}
<div>
<button class="next-button" type="button">Next</button><div class="next-point"></div>
</div>
...but if I try to do it using ::after it just doesn't work out. Here's how I've tried that:
.next-button {
font-family: 'Source Sans Pro', Arial, Helvetica, sans-serif;
text-decoration: none;
color: #fff;
text-align: center;
border: none;
background-color: #2399e5;
display: inline-block;
height: 36px;
line-height: 36px;
padding: 0 1rem;
}
.next-button::after{
content: " ";
vertical-align: top;
width: 0;
height: 0;
display: inline-block;
border-top: 18px solid transparent;
border-bottom: 18px solid transparent;
border-left: 18px solid #2399e5;
border-right: 18px solid transparent;
}
<div>
<button class="next-button" type="button">Next</button>
</div>
I've fiddled around with this for a good while and clearly I don't fully understand how to use ::after. How would I accomplish the button look in my first snippet using ::after instead of creating a separate div?

The pseudo element is a child of the .next-button element, so it's displayed inside the button. You can display it outside the button using absolute position, and a right equal to minus the pseudo element width (width = 36px -> right = -36px).
.next-button {
position: relative;
font-family: 'Source Sans Pro', Arial, Helvetica, sans-serif;
text-decoration: none;
color: #fff;
text-align: center;
border: none;
background-color: #2399e5;
display: inline-block;
height: 36px;
line-height: 36px;
padding: 0 1rem;
}
.next-button::after {
position: absolute;
content: "";
top: 0;
right: -36px;
width: 0;
height: 0;
display: inline-block;
border-top: 18px solid transparent;
border-bottom: 18px solid transparent;
border-left: 18px solid #2399e5;
border-right: 18px solid transparent;
}
<div>
<button class="next-button" type="button">Next</button>
</div>
Another options is to position absolutely inside the element to the right, and use translateX(100%) to to push it outside.
.next-button {
position: relative;
font-family: 'Source Sans Pro', Arial, Helvetica, sans-serif;
text-decoration: none;
color: #fff;
text-align: center;
border: none;
background-color: #2399e5;
display: inline-block;
height: 36px;
line-height: 36px;
padding: 0 1rem;
}
.next-button::after {
position: absolute;
content: "";
top: 0;
right: 0;
transform: translateX(100%);
width: 0;
height: 0;
display: inline-block;
border-top: 18px solid transparent;
border-bottom: 18px solid transparent;
border-left: 18px solid #2399e5;
border-right: 18px solid transparent;
}
<div>
<button class="next-button" type="button">Next</button>
</div>

A much more elegant solution would be something alone those lines:
.arrow-clip{
clip-path: polygon(0% 0%, 80% 0, 100% 50%, 80% 100%, 0% 100%);
background-color: #2399e5;
color: #fff;
padding: 0.2rem 2rem;
border: 0px;
}
<button class="arrow-clip">Next</button>
If you would like to adjust the curves of your arrow you could google a simple clip generator, I think this one is nice.

Related

Display three colors in a single DIV Element with Text

How can I display this CSS icon using only a single DIV? I thought of a linear gradient as background, but I couldn't realize it myself until now.
Here you can see that it should work theoretically (of course with different colors).
How to color a single div with 3 different colors? (one third blue, one third white, one third red)
The first snippet shows how it should look, the second snippet is a very bad trial from me and somehow it does not turn out as it should even the hover effect fails... does anyone can get the whole thing right to work?
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
cursor: pointer;
text-align: center;
background-color: white;
border: 2px solid black;
border-radius: 3px;
float: left;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.blackframe {
text-align: center;
background-color: black;
cursor: pointer;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
margin: 12px 0 12px 0;
color: white;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">
<div class="blackframe">URL</div>
</div>
<div class="whitepaper">
<div class="blackframe">URL</div>
</div>
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background: linear-gradient(to top, white 10px, black 1px, white);
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size: 12px;
font-weight: bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>
The way linear-gradient works is that the colors and values you list are stops, and CSS automatically fills in the space in between and blends it in a gradient. As mentioned in the linked question, the way to get sharp, instant transitions between colors is to create two stops at the same location: one with the old color, and one with the new. That way, there is no "in-between" space to fill with a gradient. You basically just list the starting and ending points for each color as stops, which is what I did here.
The reason your background colors weren't getting overridden on :hover is that you used background-color under the :hover selector, which doesn't override a linear-gradient. If you switch it to background, as I did, it works fine. I believe this sample works identically to the example you gave. You can adjust the px values in the linear-gradient if I didn't get them perfect.
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background: linear-gradient(to top, white 12px, black 12px, black 28px, white 28px);
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size: 12px;
font-weight: bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>
Made some small changes. Changed the linear gradient into something opaque and added background sizing.
You can adjust the black part's size with background-size.
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background-color: white;
background-image: linear-gradient(to right, rgba(0, 0, 0, 100) 50%, rgba(0, 0, 0, 100) 50%);
background-size: 100% 50%;
background-position-y: center;
background-repeat: no-repeat;
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size:12px;
font-weight:bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>

Why is second class not assigned to input element

I have designed an input button in SCSS
.editButton /* button in edit window */
{
font-weight: bold;
font-size: 12px;
width: auto;
height: auto;
padding: 2px 5px 2px 5px;
border: 0.1em solid var(--edit-button-border-color);
color: var(--edit-button-text-color);
background: var(--edit-button-bg-color);
border-radius: 4px;
.fullWidth
{
width: 100% !important;
}
}
which is leading into css file
.editButton {
font-weight: bold;
font-size: 12px;
width: auto;
height: auto;
padding: 2px 5px 2px 5px;
border: 0.1em solid var(--edit-button-border-color);
color: var(--edit-button-text-color);
background: var(--edit-button-bg-color);
border-radius: 4px;
}
.editButton .fullWidth {
width: 100% !important;
}
My HTML
<input type = "button" id = "pmLettersEditFilterSend" class = "editButton fullWidth" value = "...">
But the fullWidth is not assigned to the element. Webdevelopers output:
<input type="button" id="pmLettersEditFilterSend" class="editButton fullWidth" value="Create Letter">
and the Filter styles:
element {
}
.editButton {
font-weight: bold;
font-size: 12px;
width: auto;
height: auto;
padding: 2px 5px 2px 5px;
border: 0.1em solid var(--edit-button-border-color);
color: var(--edit-button-text-color);
background: var(--edit-button-bg-color);
border-radius: 4px;
}
.pmLettersFilterFilterTitleDiv {
text-align: left;
font-weight: bold;
font-size: 12px;
color: var(--filter-accordeon-button-text-color);
}
#pmLettersEditTemplateDiv {
font-weight: bold;
font-size: 12px;
}
So what am I doing wrong?
It's because you are actually selecting a child element instead of the same element in your scss. It should be:
.editButton /* button in edit window */
{
font-weight: bold;
font-size: 12px;
width: auto;
height: auto;
padding: 2px 5px 2px 5px;
border: 0.1em solid var(--edit-button-border-color);
color: var(--edit-button-text-color);
background: var(--edit-button-bg-color);
border-radius: 4px;
&.fullWidth
{
width: 100% !important;
}
}

How to add arrow on the right of drop down list button using CSS

I'm developing drop down list in polymer. Currently I have problem with CSS.
Here you can find example:
jsfiddle example
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:12px;">
<div class="button-value truncated" style="width:inherit;">
Select value very long label with dots at the end
</div>
<div class="arrow">▼</div>
</div>
</div>
I need to create the following drop down list, but I have problem with arrow visible on the right of button.
Question is, how to achieve this:
gif example
I will be very grateful for your help !!!!
You need to use this
text-overflow: ellipsis;
overflow: hidden;
then you will see the three dots after your list item, but also you need to add width for your span
width: 100px
Code example
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:12px;">
<div class="button-value truncated" style="width:158px; display: inline-block">
Select value very long label with dots at the end
</div>
<div style="display: inline-block;margin-top: 12px;vertical-align: top;"class="arrow">▼</div>
</div>
</div>
div.button.orange {
border: 1px solid #FF6200;
background: inherit;
background-color: #FF6200;
border-radius: 5px;
box-shadow: none;
font-family: 'ING Me';
font-weight: 400;
font-style: normal;
font-size: 12px;
color: white;
cursor: pointer;
height: 36px;
box-sizing: border-box;
box-shadow: 1px 1px 5px lightgray;
}
div.button.gray {
border: 1px solid #767676;
background: inherit;
background-color: white;
border-radius: 5px;
box-shadow: none;
font-family: 'ING Me';
font-weight: 400;
font-style: normal;
font-size: 12px;
color: #FF6200;
cursor: pointer;
height: 36px;
box-sizing: border-box;
box-shadow: 1px 1px 5px lightgray;
position:relative;
}
div.button.gray.initial {
color: #767676;
}
div.button.active {
border-radius: 4px 4px 0px 0px;
border: 1px solid #FF6200;
}
div.button-value {
text-align: center;
line-height: 36px;
width: inherit;
}
ul.options>li {
padding-left: 12px;
padding-right: 12px;
line-height: 36px;
}
.truncated {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
ul.options {
color: black;
list-style-image: none;
list-style: none;
list-style-type: none;
border-radius: 0px 0px 4px 4px;
box-sizing: border-box;
position: absolute;
width: auto;
margin: -1px;
padding: 0;
list-style: none;
border: 1px solid #FF6200;
border-top: none;
background-color: white;
box-shadow: 1px 1px 5px lightgray;
}
ul.options>ul {
list-style-type: none;
padding: 0px;
margin: 0px;
}
ul.options>li:hover {
color: white;
background-color: #FF6200;
text-decoration: underline;
}
.arrow{
position:absolute;
right:4px;
top:0;
line-height:36px;
}
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:18px;">
<div class="button-value truncated" style="width:inherit;">
Select value very long label with dots at the end▼
</div>
<div class="arrow">▼</div>
</div>
</div>

Need help for CSS Psuedo elements in Custom Css skin Telerik Controls

So here is poor me,trying to apply custom css to RadTabStrip with following css and html.Although this is telerik control but the problem is just pure css/html.
I am trying to design Menubar as shown in image below.
Please note that i dont want to use RadTemplate,so i can not change DOM here.
Please look at code snippet and images below to get an idea of problem!
<div class="RadTabStrip_Custom">
<div class="rtsLevel rtsLevel1">
<ul class="rtsUL">
<li class="rtsLI FirstChild">
<span class="rtsLink">
<span class="rtsTxt">Delivery Settings</span>
</span>
</li>
<li class="rtsLI rtsSelected selectedLI rtsClicked">
<span class="rtsLink">
<span class="rtsTxt">Pick a Template</span>
</span>
</li>
<li class="rtsLI LastChild rtsClicked">
<span class="rtsLink">
<span class="rtsTxt">Almost Done</span>
</span>
</li>
</ul>
</div>
</div>
I have used ::after and ::before to get arrow effect but the thing is when it is selected it should only display border not whole arrow with background-color.I am lost over here,even tried ::after(2) and ::before(2) but i came to know from from here that it is not supported in major browser.How can i get this effect?
.RadTabStrip_Custom {
color: #000;
font: 12px "Segoe UI",Arial,Helvetica,sans-serif;
line-height: 26px;
background-color: #ffffff;
width: 100%;
}
.RadTabStrip_Custom .rtsUL {
margin: 0;
padding: 0;
list-style: none;
width: 80%;
border: 0px solid red;
}
.RadTabStrip_Custom .rtsLI {
width: 20%;
overflow: visible !important;
position: relative;
left: 4px;
}
.RadTabStrip_Custom .rtsLI .rtsFirst {
overflow: hidden !important;
}
.RadTabStrip_Custom .rtsGhostTab {
border-color: #0f1d48;
border-radius: 5px;
color: #fff;
background-color: #324d92;
}
.RadTabStrip_Custom .rtsLI {
color: #fff;
font-size: 18px;
font-family: "Segoe UI",Arial,Helvetica,sans-serif;
margin-right: 1%;
background-color: #ffffff !important;
background-image: none !important;
color: #b7d6e8 !important;
padding: 9px;
}
.RadTabStrip_Custom .rtsLink, .RadTabStrip_Custom .rtsLink:hover {
background-color: #044666;
background-image: none;
color: #fff;
font-size: 18px;
font-family: "Segoe UI",Arial,Helvetica,sans-serif;
margin-right: 1%;
padding: 9px;
}
.RadTabStrip_Custom .rtsSelected .rtsLink, .RadTabStrip_Custom .rtsSelected .rtsLink:hover {
background-color: #ffffff;
background-image: none;
color: #b8d5e5;
font-size: 18px;
font-family: "Segoe UI",Arial,Helvetica,sans-serif;
margin-right: 1%;
padding: 9px;
border-top: 1px solid #b8d5e5;
border-bottom: 1px solid #b8d5e5;
}
.RadTabStrip_Custom .rtsLink::before {
content: "";
position: absolute;
top: 50%;
margin-top: -22px;
border-width: 22px 0 22px 16px;
border-style: solid;
border-color: #004466 #004466 #004466 transparent;
left: -7px;
}
.RadTabStrip_Custom .rtsLink::after {
content: "";
position: absolute;
top: 50%;
margin-top: -22px;
border-top: 22px solid transparent;
border-bottom: 22px solid transparent;
border-left: 16px solid #004466;
right: -5px;
}
.FirstChild .rtsLink {
border-left: 1px solid #b8d5e5;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.FirstChild .rtsLink::before {
content: "";
border-width: 0;
}
.LastChild .rtsLink {
border-right: 1px solid #b8d5e5;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
.LastChild .rtsLink::after {
content: "" !important;
border-top: 0 solid transparent;
border-bottom: 0 solid transparent;
}
"pick a template" tab is selected in both images,No worries about inverse color scheme.
What i have design till now
What i want to design
To achieve that (if I understand what you want to do), you will have to apply the :hover on the <li> but not on <span>.
Doing so you will be able to use pseudo-elements on both of them doing something like :
li:hover:before {
//do my border-bottom stuff
}
li:hover .rtsLink:before {
//do my arrow stuff
}
li:hover .rtsLink:after {
//do my arrow stuff
}
Let me know if it's what you wanted of if I'm not clear.
I used ::before and ::after for inner span "rtsTxt" and it worked... :)
.RadTabStrip_Custom .rtsSelected .rtsLink .rtsTxt::before
.RadTabStrip_Custom .rtsSelected .rtsLink::before

Draw a quarter circle and a line with css

I need to make a box using css containing arc as shown in image . I want to do this using pure CSS. I am able to make arcs but not able to draw line. Here is my html and css code.
<style type="text/css">
.left_arc{
border-bottom: 1px solid #D0BFA6;
border-radius: 0 0 360px 0;
border-right: 1px solid #D0BFA6;
float: left;
height: 11px;
padding-top: 1px;
width: 11px;
}
.right_arc{
border-bottom: 1px solid #D0BFA6;
border-left: 1px solid #D0BFA6;
border-radius: 0 0 0 360px;
float: left;
height: 11px;
padding-top: 1px;
width: 11px;
}
.text_arc {
background: none repeat scroll 0 0 #FEEEEA;
border-top: 1px solid;
color: #A29061;
float: left;
font-family: times new roman;
font-size: 16px;
font-style: italic;
letter-spacing: 1px;
padding-left: 18px;
padding-top: 6px;
text-transform: uppercase;
width: 88px;
}
</style>
<div class="main_style">
<div class="left_arc"></div>
<div class="text_arc">Canada</div>
<div class="right_arc"></div>
</div>
Here is the output of my code.
LIVE DEMO
Simplify your HTML markup
and create crazy things using the CSS pseudo :before and :after selectors
HTML
<div class="main_style">
<div class="text">Canada</div>
</div>
<div class="main_style">
<div class="text">USA</div>
</div>
CSS:
.main_style {
background: none repeat scroll 0 0 #FEEEEA;
font: italic normal normal 16px/1em Times, "Times New Roman", serif;
text-transform: uppercase;
text-align:center;
letter-spacing: 1px;
color: #A29061;
position:relative;
overflow:hidden;
float: left;
}
.text{
border: 1px solid #D0BFA6;
padding:8px 20px 4px;
}
.main_style:before, .main_style:after{
content:'';
position:absolute;
top:-13px;
width:24px;
height:24px;
background:#fff;
border: 1px solid #D0BFA6;
border-radius: 42px;
}
.main_style:before{
left:-13px;
}
.main_style:after{
right:-13px;
}
You can just create a border with negative radius for only the top corners. See this post for more info...
Add extra Corner class to your left_arc and right_arc divs.
That will be shown in this JSBin.
.text_arc {
background: none repeat scroll 0 0 #FEEEEA;
border-top: 1px solid;
color: #A29061;
float: left;
font-family: times new roman;
font-size: 16px;
font-style: italic;
letter-spacing: 1px;
padding-left: 18px;
padding-top: 6px;
text-transform: uppercase;
width: 100px;
}
.corner {
position: absolute;
height: 10px;
width: 10px;
border: 1px solid #333;
background-color: #fff;
}
.left_arc {
top: -1px;
left: -1px;
border-radius: 0 0 100% 0;
border-width: 0 1px 1px 0;
}
.right_arc {
top: -1px;
left: 110px;
border-radius: 0 0 0 100%;
border-width: 0 0 1px 1px;
}
.main_style {
position: relative;
margin: 30px;
width: 119px;
height: 28px;
background: #ccc;
border: 1px solid #333;
}