Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I've created a grid portfolio page on my website and I'm looking to add a feature to the thumbnails. I'd like that whenever someone hovers over a thumbnail, it will show the post title, date of post and excerpt.
I've been trying to find an example of what I mean and this is very similar;
http://lucybenson.net/redesign2011/
So far my loop on Wordpress looks like this
http://pastie.org/2135220
Is there a plugin that does this? If not, would anyone be able to tell me how I could achieve this?
Thanks in advance.
There are plugins for this kind of thing, but it's very easy to do by yourself.
This isn't tested, but it should get you going in the right direction:
<style type="text/css" media="screen">
.image-list {
list-style-type: none;
margin: 0;
padding: 0;
}
.image-list li {
margin: 0 10px 0 0;
padding: 0;
float: left;
}
.image-list li a {
display: block;
position: relative;
height: 50px;
width: 50px;
}
.image-list li a span {
display: block;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.4);
color: #fff;
}
</style>
<ul class="image-list">
<li>
<a href="#">
<img src="myimage.jpg" alt="My Image">
<span>
This is my overlay content
</span>
</a>
</li>
</ul>
<script type="text/javascript">
$(function() {
$(".image-list li a").hover(
// Mouse Over
function() {
$(this).find("span").fadeIn();
},
// Mouse Out
function() {
$(this).find("span").fadeOut();
}
);
});
</script>
If you're looking for a javascript-independent solution - I know, sounds really silly but it's worth a try - you can do it through CSS purely. It's not too hard - http://jsfiddle.net/teddyrised/TWBhU/
What I did was to use the -webkit-transition / transition property. Of course, my solution isn't as elegant as what Jesse has posted, but it's just nice to know CSS could work some magic, too.
There are a few things you need to get sorted here - first you need to get your head around getting one thing on top of the other - so here's the effect you're after done really simply in just css using the :hover class. The key is using the absolute position in an absolutely positioned wrap to get the text on top of the image
http://jsfiddle.net/aDwe4/
Next you want the fade the item - some people might not like it - but jquery makes this super easy - drop the hover class and put the animate function in your footer in some script tags
http://jsfiddle.net/aDwe4/1/
Finally you now need to translate this into your wordpress tempalte - I'm not sure what's going on with your template - so I'll just write an example. I would install the get_the_image plugin then put something like this within your loop
<div class="imagewrap">
<div class="image">
<?php if ( function_exists( 'get_the_image' ) ) get_the_image(); ?>
</div>
<div class="copy">
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</div>
</div>
You're obviously going to have to look up how get_the_image works, but I think with all this you should be laughing!
Related
So, I built a website and now I'm turning it into a customizable wordpress theme.
The thing is: I used CSS grid to build a gallery, and I want to make it dynamic. I need to upload the photos (and sometimes videos or gifs) in wordpress and have them fit in the grid.
This is my code:
**HTML**
<div class="gallery">
<figure class="figure1">
<img src="img/r1.jpg" class="figure-img">
</figure>
<figure class="figure2">
<img src="img/r2.jpg" class="figure-img">
</figure>
<figure class="figure3">
<img src="img/r3.jpg" class="figure-img">
</figure>
<figure class="figure4">
<img src="img/r4.jpg" class="figure-img">
</figure>
<!-- more figures -->
</div>
**CSS**
.gallery {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
}
.figure-img {
display: block;
width: 100%;
height: auto;
object-fit: cover;
margin-bottom: 0
}
.figure1 {
grid-column: span 1;
}
.figure2 {
grid-column: span 3;
}
.figure3 {
grid-column: span 4;
}
.figure4 {
grid-column: span 4;
}
/* more figures */
Since some of the images are not supposed to occupy the entire row and others are (it's a bit random), I can't just use a regular gallery plugin.
I must add I'm a beginner when it comes to php...
Any ideas?
Thank you!
Have you looked into using Advanced Custom Fields Pro? You can use the repeater field and create the gallery and create custom classes to toggle each image for grid size.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have an events website with the pages Monday to Sunday. The code used in the pages is the same. The only thing thats different is the content and the meta tags. How can I have only one webpage that loads the appropriate content when the links for monday or tuesday etc is clicked. Also will this affect the SEO? Thanks!
<nav class="menu">
<ul>
<li>Monday</li>
<li>Tuesday</li>
<li>Wedneday</li>
<li>Thursday</li>
<li>Friday</li>
<li>Saturday</li>
<li>Sunday</li>
</ul>
</nav>
<div class="content">
<div class="article"><!--the days content--></div>
<div class="article"><!--the days content--></div>
<div class="article"><!--the days content--></div>
</div>
You can have multiple divs with the content you desire, hiding and showing as you need.
in HTML
<div id="container">
<button id="btnChange">Change Content</button>
<div id="red">
This is red content
</div>
<div id="blue">
This is blue content
</div>
in CSS
#container {
width:100%;
height: 100px;
background-color: green;
text-align: center;
}
#red {
width:100%;
height: 100%;
background-color: red;
}
#blue{
width:100%;
height: 100%;
background-color: blue;
display: none;
}
in jquery
$(document).ready(function () {
var content = "red";
$("#btnChange").click(
function () {
if(content == "red"){
$("#red").hide();
$("#blue").show();
content = "blue";
}else if (content == "blue"){
$("#blue").hide();
$("#red").show();
content = "red";
}
}
);
});
heres the fiddle
Other way more elegant but complex is to have a content div, and load the content via an ajax call from jquery to the php, then clear and repopulate the div with jquery.
Hope it helps
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
My image link has "invisible pixels" that show up as a link when you hover above the actual image. Is there any way to remove them? Here is my code:
<div id="sidebar">
<div id="navbuttonbox">
<img src="img/test.png"/>
</div>
</div><!--sidebar-->
For the style I use
#navbuttonbox {
margin-left: 37px;
}
So that It will be right where I want it.
I demonstrated it on JSFIDDLE
https://jsfiddle.net/1g2pqwy2/1/
When you move your mouse a little bit above the image you still get a cursor link because the tail of the image is higher then the body.
First here is your HTML.
<div id="sidebar">
<div id="navbuttonbox">
<img src="img/test.png">
</div>
</div>
Try this:
HTML
<div id="sidebar">
<div class="navbuttonbox">
Movies
</div>
<div class="navbuttonbox">
OTHER
</div> <!--- KEEP REPEATING FOR EACH MENU ITEM //-->
</div>
CSS
.navbuttonbox {
position:relative;
background: url(/img/test.png);
background-repeat: no-repeat;
min-height: 40px;
padding-top: 10px;
margin-right: -38px;
}
.navbuttonbox > a {
display:block;
padding:10px;
}
You'll notice the link is shifted down for those invisible pixels. The tail can be fixed too if you need it with:
.navbuttonbox > a:before {
content:'';
width:38px;
top:-10px;
bottom:0;
right:0;
position:absolute;
}
To demonstrate I set up a JSFiddle: here
Sorry if this is a bit dumb but I have never dabbled with PHP before.
Basically I am using a premium wordpress theme called Kingsize, which is beautiful but does not have the author displayed on a post. I have managed to get it in there, on the individual post (by editing single.php) and the post list (loop.php).
I guess I did that sort of right because it is appearing in there. Problem is in both instances it is on the line beneath the date and I want it on same line:
http://bathastronomers.co.uk/category/bath-astronomers/
I thought I could figure it out if I found "post_date" in the style.css but it doesn't appear to be there!
Also, I want rid of the little icons before date and author.
Any ideas?
Here's the relevant code in single.php:
<?php
if( $data['wm_date_enabled'] == '1' ) { //data is enabled
?>
<div class="metadata">
<p class="post_date"><?php the_time(get_option('date_format'));?></p>
<p class="post_author"><?php the_author(); ?></p>
</div>
<?php}
?>
Change it to:
<div class="metadata">
<p>
<span class="post_date"><?php the_time(get_option('date_format'));?></span>
<span class="post_author"><?php the_author(); ?></span>
</p>
</div>
If you want the author to appear on the same line as the Date, add this to your style.css :
.post .metadata p.post_date {
float:left;
}
If you want to hide the small icon on the left, modify the following :
.post .metadata p {
padding: 0px 0px 0px 25px;
background: url("images/calendar.png") no-repeat scroll left -1px transparent;
}
For the following :
.post .metadata p {
padding: 0px;
}
Note that you don't "style PHP". You style HTML. To put it simply, PHP is a HTML generator.
I'm creating an e-commerce site and I'm having trouble vertically centering all my thumbnails. The problem is all my images are different sizes and getting each one to vertical align across all browsers is turning out to be a pain. I've looked into the different CSS options, display-table, line-height, and others. They worked in modern browsers, but not well in IE (of course). My thought is the large big time sites are resizing the image (which I can do with no problem) and then overlaying the image on top of a background the exact size they need. Does anyone know if this is how it's done? IF so can you direct me to some documentation of how to do this in PHP?
Or if someone thinks I can do this without all the extra work of overlaying images please let me know. In-case you want to see what I'm working with here ya go:
HTML
<a href="#">
<div id="product">
<div id="product-image">
<img src="" border="0" />
</div>
<div id="product-name"></div>
<div id="product-price"></div>
</div>
</a>
OPTION 1 : JQUERY (this seemed to be my best hope, but couldn't get it to work right)
var h = $('#product-image').height();
$.map($('#product-image img'), function(e)
{
var top =( h- $(e).height())/2;
$(e).css("margin-top",top);
});
OPTION 2 : CSS
#product
{
float:left;
margin:5px;
width:200px;
height:200px;
border:1px solid #999;
}
#product-image
{
margin:2px auto;
width:194px;
height:145px;
text-align:center;
}
#product-image img
{
max-height: 100%;
max-width: 100%;
vertical-align:middle;
}
EDIT
I found the working code, thanks Explosion Pills. For anyone trying to get this work I would suggest using this jQuery method and Fiddle link http://jsfiddle.net/9VfUS/1/:
WORKING JQUERY
var h = $('div#product-image').height();
$('div#product-image img').each(function ()
{
var top = (h - $(this).height()) / 2;
$(this).css("margin-top",top);
});
If you can use JavaScript, I would do it that way as it's surefire to get things to work the way you want. You are using .map for the wrong purpose. You want .each:
$('#product-image img').each(function () {
var top = (h - $(this).height()) / 2;
$(this).css("margin-top",top);
});
I assume that h was already calculated correctly as the tallest image or the height of the container or what have you. If it's not, then you have to do that.
Try this, if you know in advance the sizes of your images...
HTML:
<a href="#">
<div class="product">
<div class="product-image" data-image-loc="path_to_your_image"> </div>
<div class="product-name"></div>
<div class="product-price"></div>
</div>
</a>
CSS:
div.product-image {
background-position:center center;
background-repeat:no-repeat;
background-color: transparent;
background-attachment: scroll;
}
div.product-image-width-x-height {
width:{width}px;
height:{height}px;
}
JS:
$(document).ready(function() {
$('div.product-image').each(function() {
$(this).css({backgroundImage:url($(this).attr('data-image-loc'))});
});
});
If you don't know your sizes, then a resize script that serves all your images to a new size would fix that, and you would simply move the width/height css properties to the div#product-image CSS declaration.