PureCSS button href link not working - css

I am using purecss to create colored buttons, href is not clickable and working. The button appears fine its just the link that is cause the trouble.
<button class='pure-u-1 pure-button pure-button-primary pure-u-md-2-5 button-xlarge' href='#' >Find out more details</button>
I am not able to click the button. Why is this not working?
The button is a large one and looks like this. Please how can i fix this?
My button CSS is like this:
/*
* -- PURE BUTTON STYLES --
* I want my pure-button elements to look a little different
*/
.pure-button {
background-color: #1f8dd6;
color: white;
padding: 0.5em 2em;
border-radius: 5px;
}
a.pure-button-primary {
background: white;
color: #1f8dd6;
border-radius: 5px;
font-size: 120%;
}
.button-xsmall {
font-size: 0.5vw;
}
.button-small {
font-size: 1vw%;
}
.button-large {
font-size: 2vw%;
}
.button-xlarge {
font-size: 2.5vw;
}
.button-success,
.button-error,
.button-warning,
.button-secondary {
color: white;
border-radius: 4px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.button-success {
background: rgb(28, 184, 65); /* this is a green */
}
.button-error {
background: rgb(202, 60, 60); /* this is a maroon */
}
.button-warning {
background: rgb(223, 117, 20); /* this is an orange */
}
.button-secondary {
background: rgb(66, 184, 221); /* this is a light blue */
}

The href is just '#', which is a blank placeholder for anchor tags in HTML. The easiest solution is to just wrap your button in an <a> tag. For example:
<a href="http://www.google.com">
<button class='my-class'>Find out more details!</button>
</a>

There isn't a href attribute on a button, you would either have to add an onClick="" event or use a simple anchor tag
/*
* -- PURE BUTTON STYLES --
* I want my pure-button elements to look a little different
*/
.pure-button {
background-color: #1f8dd6;
color: white;
padding: 0.5em 2em;
border-radius: 5px;
}
.button-xsmall {
font-size: 0.5vw;
}
.button-small {
font-size: 1vw%;
}
.button-large {
font-size: 2vw%;
}
.button-xlarge {
font-size: 2.5vw;
}
.button-success,
.button-error,
.button-warning,
.button-secondary {
color: white;
border-radius: 4px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.button-success {
background: rgb(28, 184, 65); /* this is a green */
}
.button-error {
background: rgb(202, 60, 60); /* this is a maroon */
}
.button-warning {
background: rgb(223, 117, 20); /* this is an orange */
}
.button-secondary {
background: rgb(66, 184, 221); /* this is a light blue */
}
<a class='pure-u-1 pure-button pure-button-primary pure-u-md-2-5 button-xlarge' href='#' >Find out more details</a>

For me, this works: http://jsfiddle.net/ysv75326/1/
All I've done is changed the <button> into <input type="button"... and given it an ID of test. Then I set up a JavaScript listener for when an element with this ID gets clicked, it runs alert("Hey");
Code Snippet:
$("#test").click(function() {
alert("Hey");
});
.pure-button {
background-color: #1f8dd6;
color: white;
padding: 0.5em 2em;
border-radius: 5px;
}
a.pure-button-primary {
background: white;
color: #1f8dd6;
border-radius: 5px;
font-size: 120%;
}
.button-xsmall {
font-size: 0.5vw;
}
.button-small {
font-size: 1vw%;
}
.button-large {
font-size: 2vw%;
}
.button-xlarge {
font-size: 2.5vw;
}
.button-success,
.button-error,
.button-warning,
.button-secondary {
color: white;
border-radius: 4px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.button-success {
background: rgb(28, 184, 65);
/* this is a green */
}
.button-error {
background: rgb(202, 60, 60);
/* this is a maroon */
}
.button-warning {
background: rgb(223, 117, 20);
/* this is an orange */
}
.button-secondary {
background: rgb(66, 184, 221);
/* this is a light blue */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" class='pure-u-1 pure-button pure-button-primary pure-u-md-2-5 button-xlarge' href='#' id="test" value="Find out more details">

Related

Modify css so as to not change text color

I am using HTML and css from sharingbuttons.io for social media buttons on a web site.
The neural button is fine:
The hover button
changes the fill color as desired. But it also changes the text color. I want the text to remain white. How do I do that?
CSS
.resp-sharing-button__link,
.resp-sharing-button__icon {
display: inline-block
}
.resp-sharing-button__link {
text-decoration: none;
color: #fff;
margin: 0.5em
}
.resp-sharing-button {
border-radius: 5px;
transition: 25ms ease-out;
padding: 0.5em 0.75em;
font-family: Helvetica Neue,Helvetica,Arial,sans-serif
}
.resp-sharing-button__icon svg {
width: 1em;
height: 1em;
margin-right: 0.4em;
vertical-align: top
}
.resp-sharing-button--small svg {
margin: 0;
vertical-align: middle
}
/* Non solid icons get a stroke */
.resp-sharing-button__icon {
stroke: #fff;
fill: none
}
/* Solid icons get a fill */
.resp-sharing-button__icon--solid,
.resp-sharing-button__icon--solidcircle {
fill: #fff;
stroke: none
}
.resp-sharing-button--twitter {
background-color: #55acee
}
.resp-sharing-button--twitter:hover {
background-color: #525250
}
.resp-sharing-button--facebook {
background-color: #3b5998
}
.resp-sharing-button--facebook:hover {
background-color: #525250
}
.resp-sharing-button--email {
background-color: #777
}
.resp-sharing-button--email:hover {
background-color: #525250
}
.resp-sharing-button--facebook {
background-color: #3b5998;
border-color: #3b5998;
}
.resp-sharing-button--facebook:hover,
.resp-sharing-button--facebook:active {
background-color: #525250;
border-color: #525250;
}
.resp-sharing-button--twitter {
background-color: #55acee;
border-color: #55acee;
}
.resp-sharing-button--twitter:hover,
.resp-sharing-button--twitter:active {
background-color: #525250;
border-color: #525250;
}
.resp-sharing-button--email {
background-color: #777777;
border-color: #777777;
}
.resp-sharing-button--email:hover,
.resp-sharing-button--email:active {
background-color: #525250;
border-color: #525250;
}
HTML
!-- Sharingbutton Facebook -->
<a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fexample.com" target="_blank" rel="noopener" aria-label="Facebook">
<div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--medium"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg></div>Facebook</div>
</a>
Did you try to add color: #fff;? Like this:
.resp-sharing-button--facebook:hover,
.resp-sharing-button--facebook:active {
color: #fff;
background-color: #525250;
border-color: #525250;
}
On this:
.resp-sharing-button--facebook:hover {
background-color: #525250
}
you can just say
color: #fff or white;
but if you are specifically targeting the facebook text, I guess just add a div around the tags you have give it a class, and do
color: #fff;

How to change the background-color of a button multiple times, in just one click?

Kindly take a look at a GIF here that I've screen recorded on my device featuring an example of a button that turns green and then turns back to the original color, and then turns to green, all of this after one click only:
How can I achieve this? All I've got is this one. And then I don't know what to do next to achieve that kind of animation. Please help.
.query__choice {
height: 2rem;
margin: 0.3rem 0.75rem;
border-radius: 5px;
font-size: 1em;
border: 1px solid lightgrey;
color: black;
}
.query__choice:hover {
font-weight: bold;
border: 2px solid lightgrey;
color: black;
}
.query__choice:active {
text-decoration: none;
color: black;
border: 2px solid rgb(57, 235, 57);
background: green;
}
<p class="query__choice" id="choice-A"></p>
<p class="query__choice" id="choice-B"></p>
<p class="query__choice" id="choice-C"></p>
<p class="query__choice" id="choice-D"></p>
I created an example with javascript. I write an animation and repeated it 3 times.
document.querySelectorAll(".query__choice").forEach(p => {
p.addEventListener("click", () => {
p.classList.add("active");
setTimeout(() => {
p.classList.remove("active");
}, (500 * 3))
// 500 * 3 = animation-duration * animation-iteration-count
});
});
.query__choice {
height: 2rem;
margin: 0.3rem 0.75rem;
border-radius: 5px;
font-size: 1em;
border: 1px solid lightgrey;
color: black;
}
.query__choice.active {
animation-name: button;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: 3;
}
.query__choice:hover {
font-weight: bold;
border: 2px solid lightgrey;
color: black;
}
.query__choice:active {
text-decoration: none;
color: black;
border: 2px solid rgb(57, 235, 57);
}
#keyframes button {
50% {
background: green;
}
}
<p class="query__choice" id="choice-A"></p>
<p class="query__choice" id="choice-B"></p>
<p class="query__choice" id="choice-C"></p>
<p class="query__choice" id="choice-D"></p>
A CSS only solution.
.query__choice {
height: 2rem;
margin: 0.3rem 0.75rem;
border-radius: 5px;
border: 1px solid lightgrey;
}
.query__choice:hover {
border: 2px solid lightgrey;
}
.query__choice {
animation:
change 0.3s linear 6 alternate, /* run the animation 6 times with alternate so we get 3 go-back*/
h 2s ; /* this will block the above animation on page load (2s > 0.3s*6) */
}
.query__choice:active {
border: 2px solid rgb(57, 235, 57);
/* on active (click) we change one of the two animations so that it's changed back
on unclick and it will get triggered */
animation:
anything, /* a random name here */
h 2s; /* we keep the "blocking" animation so it won't get triggred and block again (yes it's crazy ...)*/
}
#keyframes change {
to {
background:green;
}
}
#keyframes h {
0%,100% {background:initial;}
}
<p class="query__choice" id="choice-A"></p>
<p class="query__choice" id="choice-B"></p>
<p class="query__choice" id="choice-C"></p>
<p class="query__choice" id="choice-D"></p>
You can even consider CSS variable to have a different color for each button
.query__choice {
height: 2rem;
margin: 0.3rem 0.75rem;
border-radius: 5px;
border: 1px solid lightgrey;
}
.query__choice:hover {
border: 2px solid lightgrey;
}
.query__choice {
animation:
change 0.3s linear 6 alternate, /* run the animation 6 times with alternate so we get 3 go-back*/
h 2s; /* this will block the above animation on page load */
}
.query__choice:active {
border: 2px solid rgb(57, 235, 57);
/* on active (click) we change one of the two animations so that it's changed back
on unclick and it will get triggered */
animation:
anything, /* a random name here */
h 2s; /* we keep the "blocking" animation so it won't get triggred and block again (yes it's crazy ...)*/
}
#keyframes change {
to {
background:var(--c,green);
}
}
#keyframes h {
0%,100% {background:initial;}
}
<p class="query__choice" id="choice-A"></p>
<p class="query__choice" id="choice-B" style="--c:red"></p>
<p class="query__choice" id="choice-C" style="--c:blue"></p>
<p class="query__choice" id="choice-D" style="--c:purple"></p>

Editing R studio theme in cache.css theme file (ACE editor?)

In RStudio, I have found the cache.css files for the different themes in Rstudio. They are text files with code like this:
.ace_editor { border: 2px solid rgb(159, 159, 159); } .ace_editor.ace_focus { border: 2px solid #327fbd; } .ace_gutter { background: #232323; color: #F8F8F8; } .ace_print_margin { width: 1px; background: #232323; } .ace_scroller { background-color: #141414;
} .ace_text-layer { color: #F8F8F8; } .ace_cursor { border-left: 2px solid #A7A7A7; } .ace_cursor.ace_overwrite { border-left: 0px; border-bottom: 1px solid #A7A7A7; } .ace_marker-layer .ace_selection { background: rgba(221, 240, 255, 0.20); } .multiselect
.ace_selection.start { box-shadow: 0 0 3px 0px #141414; border-radius: 2px; } .ace_marker-layer .ace_step { background: rgb(102, 82, 0); } .ace_marker-layer .ace_bracket { margin: -1px 0 0 -1px; border: 1px solid rgba(255, 255, 255, 0.25); } .ace_marker-layer
.ace_active_line { background: rgba(255, 255, 255, 0.031); } .ace_gutter_active_line { background-color: rgba(255, 255, 255, 0.031); } .ace_marker-layer .ace_selected_word { border: 1px solid rgba(221, 240, 255, 0.20); } .ace_invisible { color: rgba(255,
255, 255, 0.25); } .ace_keyword, .ace_meta { color:#CDA869; } .ace_constant, .ace_constant.ace_other { color:#CF6A4C; } .ace_constant.ace_character, { color:#CF6A4C; } .ace_constant.ace_character.ace_escape, { color:#CF6A4C; } .ace_invalid.ace_illegal
{ color:#F8F8F8; background-color:rgba(86, 45, 86, 0.75); } .ace_invalid.ace_deprecated { text-decoration:underline; font-style:italic; color:#D2A8A1; } .ace_support { color:#9B859D; } .ace_support.ace_constant { color:#CF6A4C; } .ace_fold { background-color:
#AC885B; border-color: #F8F8F8; } .ace_support.ace_function { color:#DAD085; } .ace_storage { color:#F9EE98; } .ace_variable { color:#AC885B; } .ace_string { color:#8F9D6A; } .ace_string.ace_regexp { color:#E9C062; } .ace_comment { fontSize:4pt;font-style:italic;
color:#996633; } .ace_variable { color:#7587A6; } .ace_xml_pe { color:#494949; } .ace_meta.ace_tag { color:#AC885B; } .ace_entity.ace_name.ace_function { color:#AC885B; } .ace_markup.ace_underline { text-decoration:underline; } .ace_markup.ace_heading
{ color:#CF6A4C; } .ace_markup.ace_list { color:#F9EE98; } .ace_indent-guide { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQERH5zzBz5sz/AA5EBAYqeZXWAAAAAElFTkSuQmCC) right repeat-y; } .nocolor.ace_editor
.ace_line span {color:#CDA869 !important;} .ace_bracket {margin: 0 !important; border: 0 !important; background-color: rgba(255, 255, 255, 0.25);} .ace_marker-layer .ace_foreign_line {position: absolute; z-index: -1; background-color: rgb(65, 65, 65);}
.ace_marker-layer .ace_find_line {position: absolute; z-index: -1; background-color: rgb(134, 134, 134);} .ace_marker-layer .ace_active_debug_line {position: absolute; z-index: -1; background-color: rgb(137, 121, 38);} .ace_console_error { background-color:
rgb(65, 65, 65); }
I am trying to edit in these, and I could use some help. So far, I have only been able to change the colour of "comments" by finding and changing the colour indicated after the "ace.comment" command. But I would like to do something similar with things like the background colour, text colour, and colour of commands in R, colour of curly brackets, etc, etc.
Is this possible? If so, what things do I need to edit in order to accomplish this?
Yes it is indeed possible. (Remember to restart Rstudio after each change)
I have no experience about ACE stuff, but it's not so hard to get the meaning of the different variables.. e.g
.ace_constant.ace_numeric {
color: #4ef971;
}
...
.ace_string {
color: #6A8F9D;
}
...
.ace_keyword {
color: #85cfda;
}
are, respectively, colors of numeric objects, strings and keywords (built in-functions and console)
I found that the default web inspector with RStudio made it difficult to make edits. I have been trying for days to get folded comments to have different font attributes based on sections.
I found it was much easier using ATOM (see screenshot below). Once I found out what each variable changed I created comments in the css file to make it easier for me next time I edit. You can see in ATOM the color is shown, making it easier to identify what the variable is defining.
I am not sure if this is optimal but it is as far as I have got. I don't know why people don't comment on variable definitions, especially since some of them are not intuitive.

Bootstrap alert and close button functionality without CSS

I would like the Bootstrap alert and close button functionality. I've included the JQuery and Bootstrap javascript file in my page head but don not want the CSS in it because it overrides a ton of styling.
Currently I've added these parts of the Bootstrap to my own css to make the alert and close button appear.
.alert {
padding: 8px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px
}
.alert h4 {
margin-top: 0;
color: inherit
}
.alert .alert-link {
font-weight: 700
}
.alert>p,
.alert>ul {
margin-bottom: 0
}
.alert>p+p {
margin-top: 5px
}
.alert-dismissable,
.alert-dismissible {
padding-right: 35px
}
.alert-dismissable .close,
.alert-dismissible .close {
position: relative;
top: -2px;
right: -21px;
color: inherit
}
.alert-info {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1
}
.alert-info hr {
border-top-color: #a6e1ec
}
.alert-info .alert-link {
color: #245269
}
.alert-danger {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1
}
.alert-danger hr {
border-top-color: #e4b9c0
}
.alert-danger .alert-link {
color: #843534
}
#-webkit-keyframes progress-bar-stripes {
from {
background-position: 40px 0
}
to {
background-position: 0 0
}
}
#-o-keyframes progress-bar-stripes {
from {
background-position: 40px 0
}
to {
background-position: 0 0
}
}
#keyframes progress-bar-stripes {
from {
background-position: 40px 0
}
to {
background-position: 0 0
}
}
This CSS makes the alert work as expected. The below part is for the close button. It styling has changed a bit, but I seem to be missing a few lines of CSS. Can anyone tell me which onesm can't seem to find them.
button.close { -webkit-appearance:none;padding:0;cursor:pointer;background:0;border:0}
Target HTML:
<% if (message.length > 0) { %>
<div class="alert alert-info"><%= message %><button type="button" class="close" data-dismiss="alert">x</button></div>
<% } %>
HTML (added alert-dismissable class, changed x to ×):
<div class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert">×</button>
Message
</div>
CSS (added basic styles for close class):
.close {
float: right;
font-size: 21px;
font-weight: bold;
line-height: 1;
color: #000;
text-shadow: 0 1px 0 #fff;
filter: alpha(opacity=20);
opacity: .2;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
filter: alpha(opacity=50);
opacity: .5;
}
CODEPEN EXAMPLE

Is there a way to change "browse" in the file upload button? [duplicate]

This question already has answers here:
How to change the button text of <input type="file" />?
(23 answers)
Closed 7 years ago.
I'm not wanting to completely restyle the file upload button, I'd just like to change what the button says. Is there a way to do this?
Yes, you can customize using "label" tag and pseudo selector.
Plus: use javascript to display the filename.
http://jsbin.com/luruqo/5/edit?html,css,js,output
The base is:
/*Hide the current input file*/
input[type="file"] {
display: none;
}
/*Show the label as custom button*/
input[type="file"]+label[for] {
background-color: #0af;
color: #fff;
padding: 4px;
}
/*Prepare pseudoelement to display file selected (when input change set the title to label with js)*/
input[type="file"]+label[for]:after {
content: attr(title);
padding: 4px;
}
Here the complete snippet:
function filechange() {
var f = (this.files[0] || this.value);
document.getElementById('labelfor' + this.id).title =
(f.name || f.fileName || f.replace('C:\\fakepath\\', ''));
}
body {
font-family: arial;
}
.field input[type=file] {
display: none;
}
.field input[type=file] + label[for] {
font-size: 12px;
}
.field input[type=file] + label[for]:before {
content: attr(label);
border: solid 1px #0af;
padding: 3px 10px;
border-radius: 3px;
background-color: #def;
color: #555;
cursor: pointer;
box-shadow: none;
margin-right: 2px;
}
.field input[type=file] + label[for]:hover:before {
box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.4);
color: #dfdfdf;
background-color: #0af;
}
.field input[type=file] + label[for]:active:before {
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.4);
color: #fff;
}
.field input[type=file] + label[for]:after {
padding: 3px 10px;
content: attr(title);
}
<div class="field">
<input type="file" id="file1" onchange="filechange.call(this,event);">
<label id="labelforfile1" for="file1" label="Select a file:"></label>
</div>

Resources