I have added a My account link and a wishlist link to my header. It shows fine on the home page but when I go on to any other page, the images are no longer displayed, all I see is the Alt text.
Can someone help me tweak my code so that the same images are shown properly on all pages? :-)
I have tried to do it so that the pictures change color on hover by having one image below the other...
PHP:
<div id="myaccount">
<a href="wordpress/my-account"><img class="bottom" src="wp-
content/themes/mt_theme/images/my_account_hover.png" alt="My
Account"/>
<img class="top" src="wp-content/themes/my_theme/images/my_account.png" alt="My Account"/>
<p class="icotext">My Account</p>
</a>
</div>
<div id="wishlist">
<a href="wishlist"><img class="bottom2" src="wp-content/themes/smy_theme/images/wishlist_hover.ico" alt="Wishlist"/>
Wishlist
CSS:
#myaccount{
position: relative;
margin: 0 auto;
}
#myaccount img {
position:absolute;
left:900px;
top: -20px;
Height: 50px !important;
width: 50px !important;
}
a:hover img.top {
opacity:0;
}
.icotext{
position: absolute;
left: 890px;
top: 28px;
color: #000000
}
a:hover .icotext{
font-weight: bold;
left: 888px;
}
#wishlist{
position: relative;
margin: 0 auto;
}
#wishlist img {
position:absolute;
left:990px;
top: -20px;
Height: 50px !important;
width: 50px !important;
}
.icotext2{
position: absolute;
left: 992px;
top: 28px;
color: #000000
}
a:hover .icotext2{
font-weight: bold;
left: 990px;
}
a:hover img.top2 {
opacity:0;
}
img.bottom2 {
opacity:0;
}
a:hover img.bottom2 {
opacity:1;
}
img.bottom {
opacity:0;
}
a:hover img.bottom {
opacity:1;
I'm guessing the other pages are trying to get the images from another folder.
src="wp-content/themes/my_theme/images/my_account.png"
You are using a relative address that is interpreted as "{current folder}/wp-content/..."
Try using
src="/wp-content/themes/my_theme/images/my_account.png"
The / on the front will be interpreted as "{site_root}/wp-content/..."
Related
I want the link to cover all images, not only at the center but when you have the mouse over the image.
.moduledata{
position: relative;
width: auto;
margin: 0px !important;
max-width: 380px;
}
.moduledata > h5 {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.moduledata > h5 > a {
color: #000000;
font-weight: 300;
font-size: 38px;
}
.moduledata:hover h5 {
visibility: visible;
}
.moduledata h5 {
visibility: hidden;
}
<div class="moduledata">
<h5>{{title}}</h5>
<figure><img src="{{pageThumb}}"/></figure>
</div>
You can wrap your image inside a link so you can click everywhere on the image to follow the link.
#comehere {
margin-top: 2000px;
}
<img src="https://via.placeholder.com/150x150" alt="">
<div id="comehere">here</div>
I been trying all day to find a nice simple short pure-css/html code only to make a div disappear when a button is clicked. I would prefer CSS but if not possible will take a JS solution instead.
Lot of solutions on overflow but most use js. please take a look at my code below and add a example or suggestion below. Thanks for any help, Stewy
body {
background-color: #6B6B6B;
font-family: Arial;
color: grey;
font-size: 12px;
margin: 0px;
}
/*............... bgcover ...............*/
.bgcover {
position: fixed;
top: 50px;
left: 50px;
width: 200px;
height: 200px;
background-color: rgba(0, 0, 0, .4);
}
.call {
position: fixed;
top: 100px;
left: 100px;
}
/*........ crossfade on buttons ........*/
.hover,.nohover{
transition:.3s;
position:absolute;
}
.nohover{
opacity:0;
}
a:hover .hover{
opacity:0;
}
a:hover .nohover{
opacity:1;
}
<div class="bgcover" align="center">
<p>Button turns off this bg cover div.</p>
</div>
<div class="call">
<a href="bgcoveroff.htm">
<img src="http://wizzfree.com/pix/call2.png" width="100" class="nohover">
<img src="http://wizzfree.com/pix/call.png" width="100" class="hover"></a>
</div>
Define your interactive node and your target node.
Create event listener to handle click event.
create a function which would hide your second element
const button = document.getElementById('button'); // or classname, whatever. it is your link or any node element instead of it.
const div = document.getElementById('targetDiv');
function toggleDiv(e) {
// e - event object - {button}.
e.preventDefault(); // only if you use <a> as node.
div.classList.add("my-classname-to-hide-div");
}
button.addEventListener('click', toggleDiv, false);
css
.my-classname-to-hide-div {
display: none;
// or
opacity: 0;
visibility: hidden;
transition: all 0.2s all;
}
ps. if you use JQuery the code could be much simpler and you can use built-in transition effects.
You have to pass the the inline JS in tag. than only possible to hide the element. onclick attribute should need to trigger.
Like this Click
Hi Stewy please check this code. It is example of the inline js.
body {
background-color: #6B6B6B;
font-family: Arial;
color: grey;
font-size: 12px;
margin: 0px;
}
/*............... bgcover ...............*/
.bgcover {
position: fixed;
top: 50px;
left: 50px;
width: 200px;
height: 200px;
background-color: rgba(0, 0, 0, .4);
}
.call {
position: fixed;
top: 100px;
left: 100px;
}
/*........ crossfade on buttons ........*/
.hover,.nohover{
transition:.3s;
position:absolute;
}
.nohover{
opacity:0;
}
a:hover .hover{
opacity:0;
}
a:hover .nohover{
opacity:1;
}
.hidden{
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="bgcover" id=box align="center">
<p>Button turns off this bg cover div.</p>
</div>
<div class="call">
<a id="btn" onclick="document.getElementById('box').classList.toggle('hidden');" >
<img src="http://wizzfree.com/pix/call2.png" width="100" class="nohover">
<img src="http://wizzfree.com/pix/call.png" width="100" class="hover"></a>
</div>
basically all i want to do is: Have a picture and when someone hovers over it i want some text to appear in its position(in the middle to be exact). What I have done so far is make the picture disappear on hover but i cannot get the text to be appeared..
Html:
<div class="container">
<img id="atp "class="atp" src="atp.jpg">
<div class="center">Some text</div>
</div>
Css:
atp{
display:block;
margin-left:auto;
margin-right:auto;
width:27%;
height:50%;}
container{
position: relative;
text-align: center;
}
.center{
position: absolute;
top:50%;
left:50%;
opacity: 0;
}
So basically, what i seek to be done is .atp:hover{opacity:0;} and what I also want is on atp's hover the .center{opacity:1;] So is there a way to put the opacity of center's to 1 when I am in the atp:hover{} code block?
Hope everything looks fine, thanks in advance!
Here is the code. Hope it will help you. if any changes please let me know.
/********* Simple or original overlay *******/
/* Main container */
.overlay-image {
position: relative;
width: 100%;
}
/* Original image */
.overlay-image .image {
display: block;
width: 100%;
height: auto;
}
/* Original text overlay */
.overlay-image .text {
color: #fff;
font-size: 30px;
line-height: 1.5em;
text-shadow: 2px 2px 2px #000;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
/********* Overlay on hover *******/
/* New overlay on hover */
.overlay-image .hover {
position: absolute;
top: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
}
/* New overlay appearance on hover */
.overlay-image:hover .hover {
opacity: 1;
}
/********* Background and text only overlay on hover *******/
.overlay-image .normal {
transition: .5s ease;
}
.overlay-image:hover .normal {
opacity: 0;
}
.overlay-image .hover {
background-color: rgba(0,0,0,0.5);
}
<div class="overlay-image">
<a href="LINK_URL">
<div class="normal">
<div class="text">Image + text ORIGINAL</div>
</div>
<div class="hover">
<img class="image" src="https://dummyimage.com/200x150/00ccff/fff.png" alt="Alt text hover" />
</div>
</a>
</div>
#atp {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
width: 27%;
height: 50%;
z-index: 50;
}
.container {
position: relative;
text-align: center;
}
.center {
position: absolute;
top: 50%;
left: 50%;
z-index: 30;
}
#atp:hover {
opacity: 0;
}
try this, using z-index. It worked with me :)
I would like to add a link to an image that has an overlay applied to it. When users hover over the image they get an opaque overlay and text appear. This works great, however I also need users to be able to click that image and taken to a link.
I have pasted my code below - the overlay works but the link portion does not. I believe it's because the overlay is interfering. I tried changing the placement of the link but was unable to do so. I am able to make the '+' be the link, but ideally the entire image should link.
Any thoughts?
JSFiddle
.roomphoto:hover .img__description { transform: translateY(0); }
.roomphoto .img__description_layer { top: 30px; }
.roomphoto:hover .img__description_layer { visibility: visible; opacity: 1; }
.img__description_layer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #cdcbca;
visibility: hidden;
opacity: 0;
display: flex;
align-items: center;
justify-content: center;
transition: opacity .2s, visibility .2s;
}
.roomphoto {
height: 166px;
}
.img__description {
transition: .2s;
transform: translateY(1em);
z-index: 999;
}
.overlay {
position: relative;
}
.overlay:after {
position: absolute;
content:"";
top:0;
left:0;
width:100%;
height:100%;
opacity:0;
}
.overlay:hover:after {
opacity: .8;
}
.blue:after {
background-color: #1a3761;
}
.img__description a {
color: #fff;
}
.roomselect {
clear: both;
float: none;
width: 100%;
max-width: 1000px;
margin: 0px auto;
padding-top: 20px;
}
.roomselect img {
width: 100%;
margin-bottom: -10px;
}
.room3 {
width: 32%;
text-align: left;
float:left;
}
<div class="roomselect"><div class="room3">
<div class="roomphoto overlay blue">
<a href="http://www.google.com">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
</a>
<div class="img__description_layer">
<p class="img__description">
<span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span>
</p>
</div>
</div>
</div>
You need to rearrange your html in such a way that when you click on image, you are actually clicking on the anchor tag. I have made some changes to your html, let me know if these work. You might have to increase roomphoto height.
<div class="roomselect">
<div class="room3">
<a href="http://www.google.com">
<div class="roomphoto overlay blue">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
<div class="img__description_layer">
<p class="img__description"><span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span></p>
</div>
</div>
</a>
</div>
</div>
What is happening
What I want to happen
I want the icon-x-circle to be horizontally centered and on the same line as "Rename" but be right-aligned (probably 30px away from the right end of the header). If someone could let me know how to do that it would be greatly appreciated!
Something to note:
The icon-x-circle itself is not centered. For some reason Fontastic icons seem to add extra space at the bottom. So this is another reason why I'm struggling to horizontally center icon-x-circle.
My Code
HTML
<div id="popup-rename" class="overlay">
<div class="popup">
<header>
<h1>Rename</h1>
<a class="close icon-x-circle" href="#"></a>
</header>
<div class="content">
<div class="student-name student-rect">
<h1>Student Name</h1>
</div>
<div class="save-button center-children">
<a class="save icon-check-circle" href="#"></a>
</div>
</div>
</div>
</div>
CSS
header{
background-color: #F5F5F5;
padding-top: 15px;
padding-bottom: 15px;
text-align: center;
text-transform: uppercase;
}
header h1 {
margin-top: 10px;
margin-bottom: 10px;
font-weight: 300; /*100, 200*/
}
.icon-x-circle{
color: #E1E1E1;
}
.overlay {
position: absolute;
z-index: 2;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
background: white;
width: 50%;
position: relative;
transition: all 200ms ease-in-out;
}
.popup header{
padding: 20px;
}
.close, .save{
transition: all 200ms;
}
.icon-x-circle:hover {
color: #B6B6B6;
}
JSFiddle
One method for aligning elements is to use position: absolute;:
.icon-x-circle {
position: absolute;
right: 0px;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;
}
You can use absolute positioning and put the button wherever you want.
first, make header a relative container
header{
position: relative;
}
Then you can make the button absolute
header a{
position: absolute;
right: 30px;
top: 10px
}
You can mess with right and top to move the button wherever.
https://jsfiddle.net/49abesy2/1/