I made a button that opens to make sort of like a drop-down page. I also made a button to retract the page and put an image in it, but I want to make the button not show up, only the image. Can anyone help?
HTML:
<button onclick="close1()"><img src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30"></button>
Here's the solution:
.transparent_button {
background-color: transparent;
border: 0px;
}
<button class="transparent_button" onclick="close1()"><img src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30"></button>
But for a better-written solution, you can try this (this won't force CSS uslessly):
<img onclick="close1()"src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30">
The solution: only set transparent border and background for it.
button {
background: transparent;
border: none;
}
<button class="transparent_button" onclick="close1()"><img src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30"></button>
If you don't need the button, but just the image to be clicked on you can leave the button out and use the following code:
<img onclick="close1() src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30" />
Maybe, if you want a border you can box it and style that:
HTML:
<div class="imageBox">
<img onclick="close1() src="https://cdn0.iconfinder.com/data/icons/user-interface-material-4-1/26/368-512.png" alt="close" width="30" />
</div>
CSS:
.imageBox{
border:1px solid #c1c1c1;
/* Other additional styles */
}
Related
Is possible to show one image and hide multiple images on button tap i AMP?
For exaplme, I have a 4 buttons (button1, button2, button3 and button4) and have 4 images (img1, img2, img3, img4). And I would like to do something like that, hit button1 and show img1, hit button2 show img2 but hide img1 and etc.
In simple way hit button to show image and hide image witch is currently on screen.
I tried to do it, but im stuck on something like this. But it won't works correctly.
<button class="button1" on="tap:img1.toggleVisibility">BUTTON1</button>
<button class="button2" on="tap:img2.toggleVisibility">BUTTON2</button>
<button class="button3" on="tap:img3.toggleVisibility">BUTTON3</button>
<button class="button4" on="tap:img4.toggleVisibility">BUTTON4</button>
<div>
<div id="img1" style=" position: absolute" hidden >
<amp-img src="img1.jpg" width="600" height="600"> </amp-img>
</div>
<div id="img2" style=" position: absolute" hidden >
<amp-img src="img2.jpg" width="600" height="600"> </amp-img>
</div>
<div id="img3" style=" position: absolute" hidden >
<amp-img src="img3.jpg" width="600" height="600"> </amp-img>
</div>
<div id="img4" style=" position: absolute" hidden >
<amp-img src="img4.jpg" width="600" height="600"> </amp-img>
</div>
</div>
I've tired with on="tap:AMP.setState({ hide: true })" and on="tap:AMP.setState({ hide: false })" but it works only for two images.
For a long time the question was unanswered, I will try to help and I hope the question is still relevant.
If I understand correctly, you want to display only image related to button id clicked at once. For simplicity of the example, I will not use images directly. Instead, we use multi-colored div's. The solution is binding hidden property to exact Id. Feel free to play with below enhanced code and css, and images if you like:
.container{
display: flex;
margin-left: 100px;
}
.box{
width: 30px;
height: 30px;
margin: 25px;
padding: 5px;
color: azure;
font-weight: 900;
}
.img1{
background: red;
}
.img2{
background: green;
}
.img3{
background: blue;
}
.img4{
background: yellow;
}
<button class="button1" on="tap:AMP.setState({id:1})">BUTTON1</button>
<button class="button2" on="tap:AMP.setState({id:2})">BUTTON2</button>
<button class="button3" on="tap:AMP.setState({id:3})">BUTTON3</button>
<button class="button4" on="tap:AMP.setState({id:4})">BUTTON4</button>
<div class="container">
<div id="img 1" class="img1 box" hidden [hidden] = "id == 1 ? false : true" >
img1
</div>
<div id="img 2" class="img2 box" hidden [hidden] = "id == 2 ? false : true" >
img2
</div>
<div id="img 3" class="img3 box" hidden [hidden] = "id == 3 ? false : true">
img3
</div>
<div id="img 4" class="img4 box" hidden [hidden] = "id == 4 ? false : true">
img4
</div>
</div>
Warm Regards,
V.
This is my code:
HTML:
<a href="index2.html">
<input type="image" class="button" value="">
</a>
CSS:
.button {
background:url(example.jpg) no-repeat;
cursor:-webkit-grab;
border: none;
}
What should happen is that it display an image and when I click on, it will navigate to another this site index2.html. It worked with another image but it had an annoying border but after I changed the image it doesn't work any more.
You do not need an input type button, simply use img...
html:
<a href="index2.html">
<img src="example.jpg" />
</a>
css:
a img {
border: none;
cursor: grab;
}
I've looked different options for aligning the FB share button with the other social media buttons, but none have worked for me yet. I'm only a few pixels off. Any ideas?
<div style="float:left; vertical-align:top">
<a class="twitter-share-button" href="https://twitter.com/share" data-url="{my url}" data-text="{text}" data-count="none" data-hashtags="{hashtag}" data-dnt="true">Tweet</a>
</div>
<div style="float:left; padding: 0 0 0 5px; vertical-align:top">
<div class="fb-share-button" data-href="{my url}" data-layout="button"></div>
</div>
<div style="float:left; padding: 0 5px; vertical-align:top">
<script type="IN/Share" data-url="{my url}"></script>
</div>
!Social Media alignment1
Change your .fb_iframe_widget class to this
.fb_iframe_widget {
display: inline-flex; /* changed line */
position: relative;
}
The facebook button has still a misalignment of one pixel.
Just add this to the css class above:
top: -1px;
P.S.: wanted to add this as a comment but I couldn't because not enough "reputation" points.
I’m using a combination of icons and text for some links in the sidebar on my website, but I want both the icon and text to change if the mouse hovers over either of them. Using MouseOn and ‘hover’ in my CSS file, I’ve managed to get this to work when the mouse hovers over the icon, but if the mouse only hovers over the text, only the text changes but not the icon as well. Does anybody know a way to do this please? A link to my site and the code I’m currently using are below. Thanks everybody.
http://www.retelevise.com
<span class="social-media-sidebar-panel">
<a href="https://www.facebook.com/re.televise" target="_external window fa">
<img src="http://www.retelevise.com/wp-content/themes/myownzee/branding/
socialmedia-facebook-1.png"
onmouseover="this.src='http://www.retelevise.com/wp-content/themes/myownzee/
branding/socialmedia-facebook-2.png'"
onmouseout="this.src='http://www.retelevise.com/wp-content/themes/myownzee/
branding/socialmedia-facebook-1.png'"
class="social-media-sidebar-icons" title="Facebook" alt="Facebook">
<span style="font-size: 0.8em">Facebook</span></a></span>
try moving your onmouseover and onmouseout events to anchor and change the 'this.' to reference the img by ID.
I've made several changes to the way you've done this:
Moved your styling and javascript to external files
Used JQuery for animations (simply easier)
This version now makes use of multiple images.
JSFiddle DEMO
HTML:
<span class="sm">
<a href="#" class="mediaLink">
<img class="mediaPic" data-hover="http://placehold.it/60/4477ee/ffffff" src="http://placehold.it/60/224499/ffffff"/>
<div class="mediaText"> Facebook</div>
</a>
</span>
<span class="sm">
<a href="#" class="mediaLink">
<img class="mediaPic" data-hover="http://placehold.it/60/ee9933/ffffff" src="http://placehold.it/60/777777/ffffff"/>
<div class="mediaText"> Stack Overflow</div>
</a>
</span>
<span class="sm">
<a href="#" class="mediaLink">
<img class="mediaPic" data-hover="http://placehold.it/60/66aaff/ffffff" src="http://placehold.it/60/3388aa/ffffff"/>
<div class="mediaText"> Twitter</div>
</a>
</span>
<span class="sm">
<a href="#" class="mediaLink">
<img class="mediaPic" data-hover="http://placehold.it/60/dd1122/ffffff" src="http://placehold.it/60/991122/ffffff"/>
<div class="mediaText"> YouTube</div>
</a>
</span>
JavaScript (Using JQuery):
$(document).ready( function() {
$(".mediaLink").on( {
mouseenter: function() {
$(this).children(".mediaPic").data("static", $(this).children(".mediaPic").attr("src"));
$(this).children(".mediaText").css("color", "orange");
$(this).children(".mediaPic").attr("src", $(this).children(".mediaPic").data("hover"));
}, mouseleave: function() {
$(this).children(".mediaText").css("color", "white");
$(this).children(".mediaPic").attr("src", $(this).children(".mediaPic").data("static"));
}
});
});
CSS:
.mediaLink {
display: block;
}
.mediaPic {
float: left;
width, height: 60px;
}
.mediaText {
height: 60px;
width: 150px;
padding-left: 10px;
line-height: 60px;
background: #242424;
color: white;
font-family: "Consolas"," Arial";
font-size: 18px;
float: left;
}
.sm {
margin: 5px;
float: left;
}
Explanation:
I'm making the <a> change its children (.mediaPic and .mediaText) when its being hovered over. On mouseenter is when the mouse is hovered over, and mouseleave is returning the <a> back to its regular state.
The part called data-hover is the url of the picture you wish to set the image to, where you leave src as the image you want to have as the default. When you hover over the image, the script will "remember" the original src and set it back to that when you leave the image (mouseleave).
I have a tab pane that is basically a line of 6 images, all floated. They are all red and the bottom border is set to 4px white by default. When a tab is selected, the 4px border turns red. Unfortunately in firefox though, there is a space between the content and the border. Right now it's a button with an image inside of it. The 1px margin between the buttons is intentional and working as expected.
The margin/padding/image-border/etc are all zero, according to the development pane, but there is still a 1px white line between the content and border ?????
You can view the webpage here:
www.bookyoursite.com/more/1
The following is the buttons with their images within:
<div id="buttonContainer">
<button id="button1" class="buttons" onclick="hideAllBut('tab',1)"><img src="/images/buttons/sites.png" /></button>
<button id="button2" class="buttons" onclick="hideAllBut('tab',2)"><img src="/images/buttons/rates.png" /></button>
<button id="button3" class="buttons" onclick="hideAllBut('tab',3)"><img src="/images/buttons/recreation.png" /></button>
<button id="button4" class="buttons" onclick="hideAllBut('tab',4)"><img src="/images/buttons/facilities.png" /></button>
<button id="button5" class="buttons" onclick="hideAllBut('tab',5)"><img src="/images/buttons/ratings.png" /></button>
<button id="button6" class="buttons" onclick="hideAllBut('tab',6)"><img src="/images/buttons/nearby.png" /></button>
</div>
CSS assosiated with the above:
#buttonContainer {
font-size:0;
text-align:center;
border-image-width:0;
}
.buttons{
font-size:inherit;
position:relative;
padding:0;
border:none;
background-color:transparent;
width:90px;
margin-right:1px;
border-bottom:4px solid white;
border-image-width:inherit;
}
.buttons img {
padding:0;
border-image-width:inherit;
}
For completeness I'll include the onclick code ... but this is probably not useful:
function hideAllBut(name,n){ //hides all other items with name, and then displays the selected tab's pane
for (i = 1;i <= 1000; i ++){
p = document.getElementById(name + i);
if (p == null)break;
p.style.display="none";
document.getElementById("button" + i).style.borderBottom="4px solid white"
}
document.getElementById(name + n).style.display="block";
document.getElementById("button" + n).style.borderBottom="4px solid red"
}
In Chrome and IE, the tabs render as desired
Try setting the images to display: block