Replace <button> with Font Awesome icon - html

I want to replace a button with a Font Awesome icon in css, but I can't hide the text of the button.
button {
border: medium none;
bottom: 0;
font-size: 35px;
left: auto;
overflow: hidden;
padding: 0;
position: absolute;
right: 20px;
top: 0;
background-color: white;
cursor: pointer;
}
button::before {
color: rgba(0, 0, 0, 0.25);
content:"";
font-family: FontAwesome;
position: absolute;
right: 0;
}
http://jsfiddle.net/evhqz1rh/2/
How can I do this?

If you really must do this with CSS only (as opposed to just removing "menu" from your HTML), you can set the overflow: visible but position the element off the screen, then adjust the :before pseudo class to move its contents back onto the screen.
#primary-navigation-menu-toggle {
border: medium none;
bottom: 0;
font-size: 35px;
left: auto;
overflow: visible; /* change to visible */
padding: 0;
position: absolute;
right: 20px;
top: 0;
background-color: white;
cursor: pointer;
right: -500px; /* position off the page */
}
#primary-navigation-menu-toggle::before {
color: rgba(0, 0, 0, 0.25);
content:"";
font-family: FontAwesome;
position: absolute;
left: -470px; /* position on the page */
}
See it on this jsFiddle.

You don't have to use a button element to do this. A simple span or div would do as both support the onClick event.
Another option is to simply remove the "Menu" text from your button code:
<button aria-expanded="false" id="primary-navigation-menu-toggle"></button>

Related

CSS: Skewed button using pseudo position: absolute

I have a button with only a single tag (<a>). I want to skew the background of the button and keep the text as is, so I'm using this code, which is working as expected in my Codepen example:
<a class="et_pb_button et_pb_pricing_table_button" href="#">$200 / Month</a>
.et_pb_pricing_table_button {
margin: 10px;
cursor: pointer;
background-color: transparent;
border: none;
height: 50px;
padding: 10px 60px;
position: relative;
color: #000000;
font-weight: bold;
text-decoration: none;
}
.et_pb_pricing_table_button:after {
z-index: -1;
content: '';
display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: skewX(-15deg);
border-radius: 0px;
background-color: #ffd100;
}
.et_pb_pricing_table_button:hover:after{
background-color: skyblue;
}
However, when I apply that code to my page, it is not rendering as expected (not visible). I can't find anything that is stopping this from working (the parent elements are position: relative). I also tried increasing the z-index of the pseudo selectors, but that didn't help either. What am I missing?

float a button to the right side

i have a menu button in the left side of website, i can't float it to the right side, i tried display properties thousands times
here my css:
.menu-button {
position: fixed;
z-index: 999999999;
margin: 1em;
padding: 0;
width: 2.5em;
height: 2.25em;
border: none;
text-indent: 2.5em;
font-size: 1.5em;
color: transparent;
background: transparent;
outline: 0;
}
and here is the site you can check the inspact element by the way : wwww.takchinsaffron.com
Add right: 0 to your selector:
.menu-button {
right: 0;
}
Add left:100% to your selector:
.menu-button {
left: 100%;
}
If the element goes out of bounds, try adding transform:translate
.menu-button {
left: 100%;
transform:translate(-100%, 0);
}

Prevent my ::after from blocking my select

Here is a fiddle demonstrating my problem: JSFiddle
I'm making a custom drop down (in reality I'm using an icomoon icon instead of the V)... it looks nice, but the ::after for the parent element is blocking the select :(
<div class="select-style">
<select>
<option value="">...</option>
<option value="1365">Some term</option>";
</select>
</div>
CSS
.select-style {
width: 240px;
height: 26px;
border: 0;
padding: 0;
margin: 0;
position: relative;
&::after {
/*content: "\f107";
font-family: "icomoon";*/
content: "V";
font-size: 18px;
position: absolute;
right: 7px;
top: 0;
}
}
select {
width: 100%;
height: 24px;
border: 1px solid rgb(199, 199, 199);
border-radius: 3px;
background-color: transparent;
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: "";
&::-ms-expand {
display: none;
}
}
I've looked into having JS open the drop down, but found out that doesn't work. I've even tried using z-index to see if that would help... but for some reason the icon gets hidden even though the select has a transparent background.
How can I make it so that the custom icon is visible over the select but does not block my select from being clicked?
Add position:relative and z-index:1 to the select itself
https://jsfiddle.net/hbpqvkqL/
select {
...
position: relative;
z-index: 1;
}
yopu can set the ::after to have z-index: -1;
.select-style {
width: 240px;
height: 26px;
border: 0;
padding: 0;
margin: 0;
position: relative;
&::after {
/*content: "\f107";
font-family: "icomoon";*/
content: "V";
font-size: 18px;
position: absolute;
right: 7px;
top: 0;
z-index: -1;
}
}

Having difficulties centering input and text with borders

I am having difficulties centering a an input and borders around text that I created. I am trying to center it with a percentages based setting, so that it becomes more responsive. It seems the percentages are off and every time I go over left: 35%;, it does not move over anymore.
The same applies to my submit button, inside of the search input. I took the percentage left out because it did not do anything.
I have stored all of my code inside of this fiddle:
https://jsfiddle.net/ghp4t489/
But, to get the best option to view what I am trying to do, is to visit my website. realtorcatch.com/test_index
How can I get the text with borders/search bar to be centered in the page?
Here is my CSS
.search_option_container_out {
text-align: center;
top: 450px;
left: 30%;
position: absolute;
z-index: 111;
}
.search_option_box {
position: absolute;
text-align: center;
left: 40%;
}
.search_option_box li {
display: inline;
border: 1px solid black;
line-height: 2em;
padding: 20px 75px;
background: rgba(24, 24, 24, 0.3);
color: #FFFFFF;
cursor: pointer;
}
.search_option_box li:hover {
background: rgba(0,0,255, 0.3);
}
.home_searchbar_out {
text-align: center;
padding-top: 60px;
}
.home_searchbar {
padding: 10px;
}
.home_search_input {
position: absolute;
left: 45%;
width: 575px;
padding: 14px;
font-size: 1.1em;
}
#home_search_submit {
padding: 11px 20px;
position: absolute;
background-color: blue;
color: #FFFFFF;
cursor: pointer;
font-size: 1.1em;
z-index: 1;
}
your code demo here: https://jsfiddle.net/ghp4t489/4/
essentially, you want to use the concept of centering a container inside the page like so:
div {
width: 100px;
height: 100px;
border: 1px solid black;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
<div>my div here</div>
this code is using margin: auto to center the div in the page.
EDIT: https://jsfiddle.net/ghp4t489/7/ with button on the right and next to the input
https://jsfiddle.net/ghp4t489/9/ with button on right inside the input

CSS tooltip getting cut off

I have a CSS tooltip that is being cut off when the hovered item is too close to the edge of the content area. See the links towards the bottom of this post: http://blog.betbright.com/top-stories/manchester-united-v-club-brugge-betting-preview/
Here is the code I'm using for the tooltip:
a.tooltip {
position: relative;
display: inline;
}
a.tooltip span {
position: absolute;
width:110px;
color: #FFFFFF;
background: #00A1E0;
height: 30px;
line-height: 30px;
text-align: center;
visibility: hidden;
border-radius: 6px;
}
a.tooltip span:after {
content: '';
position: absolute;
top: 100%;
left: 50%;
margin-left: -8px;
width: 0; height: 0;
border-top: 8px solid #00A1E0;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
}
a:hover.tooltip span {
visibility: visible;
opacity: 1;
bottom: 30px;
left: 100%;
margin-left: -76px;
z-index: 999;
}
Any solutions you can recommend to stop the tooltip being cut would be appreciated.
Thanks,
Paul
You should set the overflow property on your .entry-content class to visible instead of hidden. Your current setting hides everything that does not fit within that div. Since your tooltip would be displayed partly outside your .entry-content div, a part is cut of unless you change the overflow property. So, your error is not in the tooltip, it's in a parent element.