How to put jssor slider count in caption - php

I have a jssor slider working, including displaying captions. Each caption shows a title in the first line and a description in the lines below the title. I'm looking to add the slider count to the caption, so to the right of the title I would show, for example, "2 of 47".
Based on another post I found, I added the below code to the js:
function DisplayIndex() {
$("#displayIndex").text(jssor_slider2.$CurrentIndex() + 1 + " of " + jssor_slider2.$SlidesCount());
}
DisplayIndex();
jssor_slider2.$On($JssorSlider$.$EVT_PARK, DisplayIndex);
I also added the "<div id='displayIndex'" line to the php code, subordinate to caption div, as below:
echo "<div class='caption2_text'>";
echo "<h1>$title</h1>";
echo "<p>$desc</p>";
echo "<div id='displayIndex' u='any' style='position: absolute; top: 10px; left: 790px; width: 100px; height: 26px;'></div>";
echo "</div>";
The count appears, but is in the inner container rather than in the caption, so any full width picture overlays the count and the count is not visible.
How can I put the count into the caption itself?
Any assistance is much appreciated.

I found that you placed the displayIndex element inside a caption. You know, a caption should be a child element of a slide. It always moves along with the slide.
The more reasonable way is to make the displayIndex to be a static/fixed element.
A static/fixed element is an element parallel with every slide. It should be treated as a slide, but with u="any" attribute specified, it's no longer a slide, it will always stay where it should be.
<div u="slides">
<div><!-- slide 1 --></div>
<div><!-- slide 2 --></div>
<div id='displayIndex' u='any' style='position: absolute; top: 10px; left: 790px; width: 100px; height: 26px;'>
<!-- this is a static element -->
</div>
</div>
Reference: http://www.jssor.com/development/slider-with-fixed-static-element.html

Related

How to CONTAIN a PHP variable echoed content in a DIV

Hello My question is not how to echo a php variable into a DIV. My question is how to contain it. When I enter text into the DIV it expands and contains text, but the echoed php Variable content from the variable crosses the boundery Vertically at the bottom only. Overflow:hidden works but then it does not expand with the content.
** CSS **
.bottom-menu-body{
padding-left:20px;
padding-right:20px;
padding-bottom:20px;
** DIV **
<div class="card">
<div class="bottom-menu-body">
<?php echo $bidcard; ?> <!-- Bid Card Content from Require: db_ac_bids.php-->
<?php echo $nobids_message; ?> <!-- Bid Card Content from Require: db_ac_bids.php
CSS control via acceptbid css card-->
</div><!-- Bottom Menu body End -->
</div><!-- Card end -->
I am not able to understand the question properly but I guess below css might help you :
div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
"text-overflow: ellipsis" this will add "..." ellipsis.

If class exists give the next div a top margin but margin height determined with php

I'm trying to give the first div a top margin only if the class fixed-header exists, I've tried doing this with pure css but there were to many variables and I was losing track so I'm thinking use jquery.
Here's some simple html
<div id="page-container">
<div id="header" class="fixed-header">header</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
<div>Test 5</div>
</div>
Basically, if .fixed-header does exists give the first div, in this case it's 'test2' a top margin which matches the header, if there is no 'div2' then give 'div3' a top margin and so on.
Now for the tricky part, the top margin must be determined from a php script, here's how I get the header height below.
<?php echo $header_options['header_height'] ?>
How can I do this in jquery?
Here's a basic fiddle to start me off
If i understood you correctly, you can do that in CSS like that:
.page-container div.fixed-header:nth-child(1) + div,
.page-container div:not(.fixed-header):nth-child(1){
margin-top:20px;
// or
margin-top: <?php echo $header_options['header_height'] ?>px;
background:red;
}
this will give the first div after .fixed-header or the first one in .page-container (if no fixed-header exists) a margin.
Demo
If you want the margin be exactly the same as the height of the header without php, then yes, you'll have to resort to javascript/jquery. Something like this
$('#page-container div.fixed-header:nth-child(1)').each(function(){
$(this).next().css({'margin-top':$(this).height()});
});
Use length to find the div exits or not:
if($('.fixed-header').length > 0){
//do your stuff here
}
And I think it should work just with css:
#page-container .fix-header{
margin: 5px;
}
You can do this in CSS alone you know....you dont need to resort to Javascript or jQuery.
#page-container div:nth-child(1)[class='fixed-header']{
background:red;
}
Demo of the above, variation 1, variation 2
Use CSS in the head of the page:
#page-container #header.fixed-header + div {
/* the following should be parsed by php, but
I don't know whether this generates a full CSS
rule, or just the relevant length. Adjust as appropriate */
<?php echo $header_options['header_height'] ?>
}
There's no need for jQuery in here...
You want to div that follows .fixed-header to have a margin? Use the adjacent selector "+"
<style>
#header.fixed-header {height: <?php echo $header_options['header_height'] ?>px}
#header.fixed-header + div {margin-top: <?php echo $header_options['header_height'] ?>px}
</style>
Btw, you could just set a margin-bottom on #header.fixed-header... ;-)
Well, if each margin is the same, then give a data-attribute to the container. If each margin has different height, the most intuitive option is to put a data attribute to each item.
If each margin is the same, here is you code
$(".fixed-header").each(function(item) {
$($(item).next()).css('margin-top', $(item).parent().data('margin-height'));
});
Your markup should look like this:
<div id="page-container" data-margin-height="50px">
<div id="header" class="fixed-header">header</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
<div>Test 5</div>
</div>
This is equivalent to the following CSS, if every page-container has the same value as well.
.page-container .fixed-header + div {
margin-top: 50px;
}
You can generate this CSS file with your PHP as well. To make life easier, you can even embed this to you HTML template. If the margin-height does not reflect any information, then possibly generating your CSS is the best option, because then, you don't need to put useless information outside a <style> or <script> tag.
<style>
.page-container .fixed-header + div {
margin-top: <?php echo $header_options['header_height'] ?>;
}
</style>
Another option is to use CSS3 attr, which is not yet supported completely in all browsers.
https://developer.mozilla.org/en-US/docs/Web/CSS/attr
.page-container .fixed-header + div {
margin-top: attr(data-margin-height);
}
This allows you to get rid of your script, but unfortunately, you will have to set data-margin-height for each .fixed-header.
I used .page-container classes in these examples, because this solution can be used if you have multiple different containers on the same page. If you only need one, you can just replace each .page-container to #page-container, and the code will work. Fiddle:
http://jsfiddle.net/k5V2a/

restricting text to a certain width with css or php

I have text that I put into a div, which is generated automatically by php..(taken from the database).
But the text stretches over the div.
here is an example of what I want to do:
<div>
<?php
Generate_All_Text_Content_Here();
?>
</div>
I want the div to limit to where the text stretches..say no more than 300px.
I tried to give it width measurement..but it has no influence over the div element
add to your style
div{
max-width:300px;
word-wrap:break-word;
text-overflow:<clip> or <ellipsis>;
overflow:<hidden> or <scroll>;
}
this should really cover everything >.<
Why not do something like this then?
<div style="<?php echo get_text_width(); ?>">
<?php Generate_All_Text_Content_Here(); ?>
</div>
Just set the div width with CSS and text won't be bigger:
div {
max-width: 300px; /*Or simply width: 300px; if you want the div always to be that width*/
}

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!

CSS div height not stretching

I'm programming a website and on a page I have dynamic content. To be specific I want to display some content in a div each. And the main div wont stretch upon this content.
#main{
position:relative;
background-image:url(images/main_middle.png);
background-repeat:repeat-y;
width:850px;
min-height:450px;
}
.intrebari{
position:relative;
width:400px;
min-height:150px;
padding:20px;
}
while($row=mysql_fetch_array($rezultat)){
echo '<div class="intrebari">
<div id="upleft"></div>
<div id="upright"></div>
<div id="downleft"></div>
<div id="downright"></div>
'.$_SESSION['username'].' a intrebat:<br />
'.$row['question'].'
</div>';
}
What am I doing wrong?
The internal div has to be cleared so the outer should know the height of the inner div
you may use a class
.clear{
clear:both;
}
and introduce it after your inner div inside outer div main
echo '<div class="intrebari">
<div id="upleft"></div>
<div id="upright"></div>
<div id="downleft"></div>
<div id="downright"></div>
'.$_SESSION['username'].' a intrebat:<br />
'.$row['question'].'
</div><div class="clear"></div>';
this will help you
If you have given float to intrebari, you need to give float left or right to main div to get the main wrap the inner content
.intrebari{
position:relative;
width:100%
min-height:150px;
padding:20px;
}
if you want to have the content of the div.intrebari stretch horizontaly make the width of value to 100%

Categories