Load content dynamically [closed] - php

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

Related

Two DIV elements are not stacking correctly on mobile [closed]

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 5 years ago.
Improve this question
My CSS and HTML are not working. div2 should render below div1 but it's not working on mobile.
#div1 {
width:100%
}
#div2 {
width:100%;
}
<div id = "main">
<div id = "div1">
</div>
<div id = "div2">
</div>
</div>
div {
display:inline-block
}
#div1 {
width: 100%
}
#div2 {
width: 100%;
}
<div id="main">
<div id="div1">
</div>
<div id="div2">
</div>
</div>
making the divs diplay inline:block should solve the problem
Try this one
#div1,#div2 {
width: 100%
display:inline-block;
vertical-align: top;
}

My link image has invisible pixels that I want to remove via coding [closed]

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

Show / Hide divs individually with same class name

I am trying a really easy thing, hiding / showing an info div my mouse-hovering another element. My code structure is similar to:
<div class="divRow">
<div class="divColumn">
<div class="divInfo">Info</div><img src="" /></div>
<div class="divInfo">Info</div><img src="" /></div>
<div class="divInfo">Info</div><img src="" /></div>
</div>
</div>
Image is shown, and there should be a blank space in which I want divInfo to appear.
I am using the following jQuery code to show / hide:
$(function() {
$('.divInfo').hide();
$('.divColumn').hover( function() { $('.divInfo').toggle(); } );
});
Of course, this works, but shows / hides all 3 divs in the row at a time. I want to be able to show hide each one separately...
Is this possible using classes? Or do I have to use a different unique ID for each??
Functionality I want is shown here, but I don't know how to do that. :)
http://www.therice-co.com
Regards and thanks
Actually you want the divs to always be there but somehow "not visible" when you are not hovering them. This is as simple as:
.divInfo:not(:hover){
opacity: 0;
}
Fiddle
This is what are you trying to achieve
see http://jsfiddle.net/j0aoy47L/
Javascript
<script>
$(function() {
$('.divInfo').hover( function() {
$(this).find('.info').toggle();
} );
});
</script>
CSS
<style>
.info{
display: none;
text-align: left;
}
.divInfo{
background: #fcfcfc;
border:1px solid #e5e5e5;
width:360px;
height:200px;
position: relative;
margin-bottom: 10px;
text-align: center;
padding:10px;
}
.divInfo img{
position: absolute;
bottom: 9px;
left: 19px;
}
</style>
HTML
<div class="divRow">
<div class="divColumn">
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
</div>
$('.divColumn').children('a').hover(function () { // bind it to exact image
$(this).prev('.divInfo').toggle(); // show previous div
});
will work
jQuery DEMO
but you definetely have too much closing </div>s
also you can do it with pure CSS if you wrap each info and image in separate div and use :hover on it
PURE CSS DEMO

Wordpress: On hover load title of post into a specific DIV

I'm currently working on a wordpress template where the title of a post is hidden and on hovering the post, it should be displayed on the bottom of the browser. To simplify, the post has this structure:
<article class="post">
<header class="article-header">
<h2 class="entry-title">
Post Title
</h2>
</header>
<section class="entry-content">
Post Content
</section>
</article>
Basically, I'd like to have a fixed in the body, that sits on the bottom of the browser and when a post is hovered, the content of its child element is passed into the . My approach so far was to have all elements constantly fixed to the browser bottom (hidden) and on a hover, each of them will be display. That led to a couple of problems and I thought I'd might be easier to have one empty div, which just grabs the title information.
Can anyone help me with that, maybe with jQuery or php?
Thanks!
you mean, something like this? http://jsfiddle.net/rKhqT/5/
HTML:
<article class="post">
<header class="article-header">
<h2 class="entry-title">
Post Title
</h2>
</header>
<section class="entry-content">
Post Content
</section>
</article>
<footer></footer>
CSS:
html, body {
margin: 0;
height: 100%;
}
.entry-title {
display: none;
}
footer {
position: fixed;
left: 0;
bottom:0;
width: 100%;
height: 30px;
border: 1px solid black;
}
JS (requires jQuery) :
$(document).ready(function() {
$('article.post').mouseover(function() {
$('footer').text($(this).find('h2').text());
});
$('article.post').mouseout(function() {
$('footer').text('');
});
});

Show info when hover over thumbnail [closed]

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!

Categories