I'm trying to do something semi complicated. I have 4 linked images. when I hover over the image I want the opacity to change to 0.7. I also want a ribbon to become visible when you hover that image. Here's the code I'm using
<div id="tracks-content">
<div class="track enrolled">
<a href=""><div class="ribbon"><img src="ribbon.png"/></div>
<span><img src="images/pic-track1.png" /></span></a>
<h3>Track title 1</h3>
<span>Track description here. Lorem ipsum dolor sit amet con sectetuer adipiscing elit.</span>
</div>
<div class="track unavailable">
<a href=""><div class="ribbon"><img src="ribbon.png"/></div>
<span><img src="images/pic-track2.png" /></span></a>
<h3>Track title 2</h3>
<span>Track description here. Lorem ipsum dolor sit amet con sectetuer adipiscing elit.</span>
</div>
</div>
So if I hover over the image for say track1.png then I want track1.png to dim to 70% and I want the visibility for ribbon.png to change from hidden to visible. I keep running into a problem where the opacity of the image is also applied to the ribbon. In the image you can see when I hover the 1st image the ribbon appears but is also getting the opacity. see link for image http://img.photobucket.com/albums/v513/Tearyguitarist/example.png
Here's the css i'm using
#tracks-content .enrolled a:hover > .ribbon{
visiblity:visible;
}
#tracks-content .enrolled a:hover span img{
outline: solid 1px #40a304;
opacity:0.5;
}
Any suggestions? I can't use any position absolutes since the whole page is php driven and could have 1 or 10 tracks so the content has to be dynamic and reuseable.
I cannot recreate the issue, as it seems to work fine in this demo (note: opacity was changed just to make it more obvious). However, a few things to note that might be causing issues.
1) The most likely issue is that it is invalid html to have a div in an a tag (block level element inside an inline), so some browsers may be having issues with that and not functioning correctly.
2) If your css above reflects your true css, then you have misspelled visibility ("visiblity") in setting the ribbon to visible.
3) Have you verified that the ribbon.png itself does not have its own, inherent opacity (since it is a png, it can have opacity in image itself).
Remove your code and try border with some padding instead of using outlineUse below style:
#tracks-content .enrolled a:hover span img{
border: solid 1px #40a304;
padding:1em;
opacity:0.5;
*filter: alpha(opacity=50);
}
Related
How do I make the selected text keep its custom background color even if the selection is "out of focus"? Just follow these steps in order to better understand what I mean:
Select the text
Click, for example, in your web browser's search bar
This is the actual output for me:
Edit: The browser I am using is Firefox 58.0.2
::selection {
background-color: red;
}
::-moz-selection {
background-color: red;
}
<p>Lorem ipsum dolor sit amet</p>
You can use two things:
HTML < mark > tag:
<mark>Marked text</mark>
CSS background color:
<p style="background-color: #FFFF00">This complete paragraph of text is highlighted in yellow.</p>
Although this is really not advised, as users would like to know when something is selected or not!
I am using Marp which is a tool to create presentations in markdown and convert it into pdf. On the first slide I have some content such as this:
# <center> Working with Virtual Box </center>
<img align="right" src="images/logo.png" width="250">
All of this is top center aligned. What I would want is that the text to be middle aligned(vertically and horizontally) and the image to be bottom right aligned. I couldn't find much about it in the Marp documentation. I am hoping someone with better css know how could help! Believe me, I searched for over 2 hours on this, but my lack of css skills is getting me nowhere.
There are three options:
1. Make the image part of the background.
It sounds like you are trying to put a logo on the slide in the bottom right. In this case, if it is to be on most slides - just create a new background with the image in the bottom right. Then set the image as the slides' background, using the bg keyword in the alt-text box:
![bg](background-with-logo.jpg)
2. Create an image background and offset it.
(Perhaps less applicable for a 'logo in the corner' effect put works well for other images).
Insert the image and use the bg keyword in the alt-text box, along with the either right or left.
![bg right](image.jpg)
This can be further customised with percentages - adjusting how much of the slide is given over to the background image.
![bg right:40%](image.jpg)
The image can also be scaled with an additional percentage.
The example below sets 40% of the slide on the right-hand side over the background, and the image is then scaled to 80% of it's original size.
![bg right:40% 80%](image.jpg)
3. Use the footer directive and adjust the css to suit.
This allows for great flexibility of sizing and positioning of the image.
Use Marp's footer directive, and include the image link within that. This can be applied globally or locally to individual slides (as in the example below).
Then you can change the css to customise the size an position of the image. This can be done through a theme css or via the markdown text with tags (as below).
<!-- _footer: "![](image.jpg)" -->
<style>
footer {
height: 200px;
margin-bottom: -80px;
}
footer img {
height: 100px;
float: right;
}
</style>
# Logo - footer
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc molestie euismod ipsum, et malesuada sem condimentum a.
Sed pellentesque arcu mattis massa porttitor volutpat.
Try something like this :
![x% center](images/logo.png)
where x is your width in %
Source (french) : https://www.unixmail.fr/informatique/presentation-avec-marp/
Tested this today and it worked:
<style>
img[alt~="center"] {
display: block;
margin: 0 auto;
}
</style>
![w:640 center](image.png)
Source: https://github.com/marp-team/marpit/issues/141
Try float right inline style:
<img src="images/logo.png" style="float:right" width=250>
How to vertical align text over on the middle image, if i have html like this. I want the flow of the text to be always in the middle, even when there are one ore two lines of text.
<div class="area-position">
<img src="image.jpg" alt="image" />
<a class="image-text" href="/link">Lorem ipsum dolor sit amet, consetetur sadipscing elitr</a>
</div>
I found multiple solutions but non had the image as part of the div.
Should i generate html somehow else?
There are two ways I can think of.
Detach your image from the document flow with CSS.
div.area-position {
position:relative;
}
div.image-text {
position:absolute;
top:0;
left:0;
}
Or set your image as the background of your div.
div.area-position {
background:url('image.jpg') top left no-repeat;
}
Either way you'll need to specify a width and height for your container.
you can try this code sample
#parent {display: table}
#child {
display: table-cell;
vertical-align: middle;
}
This is an old and often forgotten display method but a good way to center align stuff
Hope this helps
Take care and happy coding
I am not good with javascript or jquery, so maybe i will get help here. I need script, which automatically find element height, and put that height as css style in div.
I made simpe hover (overlay) effect, but as you can see in demo, when i am hovering image, overlay effect shows in all div. I need, that overlay will be displayed only in image dimensions.
I found this script:
$(document).ready(function() {
$('.overlay').click (function () {
alert($(this).height());
});
});
But this script is not what i am searching for. It gives me height when i am clicking on the element. But how i can make it to show me automatically when page is loaded? How can i post height to div style?
HTML
<div class="item">
<img src="http://placekitten.com/450/550" class="image">
<a class="overlay" href="#">
<h3 class="title">Some title</h3>
<div class="description">
<p>
Lorem ipsum dolor sit amet, <br>
consectetur adipisicing elit.
</p>
</div>
</a>
<div class="information">
<span>Some information, long text... etc</span>
</div>
</div>
CSS
.overlay {
width: 100%;
background-color: rgba(0,0,0,0.5);
position: absolute;
top: 0;
left: 0;
text-decoration: none;
color: #fff;
display: none;
}
DEMO http://codepen.io/anon/pen/raVLgV
Sorry for my BAD english, and thank you for any help.
in first: make sure the jQuery has beed loaded in document, so add follow code in demo
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
Second the script
window.onload = function() {
$('.overlay').css('height', $('.image').height() );
}
why no using $(document).ready() ?
because window.onload will run after DOM and image load completed.
$(document).ready() run just DOM load completed.
Demo http://codepen.io/anon/pen/azOmom
I need an on hover semi-transparent div which causes some text to appear over the top of a thumbnail image? Is it possible to do this without using JavaScript and using just Cascading Style Sheet?
You can try something like this:
<style type="text/css">
.thumb {position:relative;width:200px;height:20px;}
.thumb:hover .overlay {opacity:0.5;}
.overlay {position:absolute;top:0;left:0;width:200px;height:20px;background:#fff;opacity:0;}
</style>
<div class="thumb">
<div class="overlay"></div>
<img src="image.gif" />
</div>
Ok ok I know this is old but i ran into and have something to add about opacity settings
http://deepubalan.com/blog/2010/03/29/rgba-vs-opacity-the-difference-explained/
give that a look over, I find using rgba when ever possible over opacity procuces a much better result, opacity can work funny in different browsers and cause all manner of asthetic problems...
just my 2 cents
Depending on what you're doing with the thumbnail, you could set the background of the DIV as the image, include the text, and use CSS to toggle the visibility from transparent to solid on hover.
This'd only work cleanly if you have a known-size thumbnail (because it's hard to autosize a div to the size of its background image), but it'll make for a simple solution in your html:
<div class="thumb" style="background-image: url(thumb.jpg);">
<p>mouseover text</p>
</div>
The important css would be something like this...
div.thumb p { visibility: hidden; }
div.thumb:hover p { visibility: visible; }
Not sure from your question whether the whole div is supposed to be transparent or just the text, but you can apply the relevant CSS at either level.