I am working on a movies website. On homepage I have created two buttons one for grid view and other for list view. The class for grid view is animation-2 items and class for list view is animation-2 items liststyle ( liststyle is added with js ) Using JS when user will click the list button list style class with be added in the main class and the view of my post will change according to the styling which i apply on this class. Now issue is as I have applied some styling and hide the images in list view it works fine til now but now when I am applying styling on my main class mean grid view same styling is applying on my list view. Here is my code:
<script>
jQuery('.grid').click(function(){
jQuery('.animation-2').removeClass('liststyle');
});
jQuery('.list').click(function(){
jQuery('.animation-2').addClass('liststyle');
});
</script>
<style>
.tablinks.selected{
color:red;
}
.tablinks.selected{
background-color: #FDB813;
color: white;
}
.liststyle article div img{
display: none!important;
}
.liststyle .poster{
height: auto!important;
padding-top: 10%!important;
}
.liststyle article{
width: 100%!important;
height: auto!important;
}
</style>
The above code is working fine and all styles are working now I want to hide a class rawsub on my grid view but same styling is applied on list view as I am giving reference of only main class animation-2 items but still style is applying on animation-2 items liststyle class.
Here is the code of my rawsub class:
<article id="post-<?php the_ID(); ?>" class="item <?php echo $posttype; ?>">
<div class="poster" style="padding-top: 1%!important; padding-bottom: 1%!important;">
<a href="<?php the_permalink() ?>">
<img src="<?php echo dbmovies_get_poster($post->ID); ?>" alt="<?php the_title(); ?>">
</a>
<div class="rawsub">
<span class="rawsub"><?php the_field('type3'); ?></span>
<span class="rawsub"><?php the_field('type'); ?></span>
<span class="rawsub"><?php the_field('type2'); ?></span>
<a href="<?php the_permalink() ?>">
<h3 class="rating"><?php the_title(); ?></h3>
</a>
</div>
<span class="posttime">
<?php the_time( 'g:i a' ); ?>
</span>
Add this code it will remove rawsub from grid view and will not change the list view
.animation-2.items article .rawsub span:nth-child(1){
display:none;
}
.animation-2.items.liststyle article .rawsub span:nth-child(1){
display:inline-block!important;
}
As you said you want to hide rawsub class,
Try this,
var rawsub_elements = jQuery('.rawsub'); // take all elements with class rawsub on page load
Now you have elements with class rawsub in rawsub_elements,
Try putting below statements in your jQuery code where you are adding and removing liststyle class,
rawsub_elements.each(function() {
$(this).toggleClass("rawsub");
});
This will toggle the class rawsub on elements having rawsub as class name, which means if class rawsub is present toggleClass will hide the class name and when class rawsub is hidden/not present toggleClass will add the class name rawsub to the element.
Related
I am trying to add '+' Symball in front of category navigation on left side
I am using magento 1.9.x
This code i fount in category-navigation.phtml
I want to know how <?php echo $_menu ?> this comes from?
<div class="block vertical-menu">
<div class="title-block" style="margin-bottom:0px;"><h4><?php echo $this->__($title) ?></h4></div>
<div class="block-content">
<ul id="content-navigation">
<?php echo $_menu ?>
</ul>
</div>
</div>
My suggestion would be to do it in CSS. You can use Ionicons or something similar.
The $_menu html is generated inside the block class, rather than using a phtml file. So, you could extend that block and customize it, but this can also be achieved using CSS without having to worry about extending the block.
An example would be the following:
Example HTML
<nav id="nav">
<ol>
<li>Plus Sign</li>
<li class="active">Minus Sign</li>
</ol>
</nav>
Example CSS - This requires Ionicons
ol {
list-style: none;
}
#nav li::before {
font-family: Ionicons;
content: '\f489';
padding-right: 10px;
}
#nav li.active::before {
content: '\f209';
}
JS Fiddle - A working sample
https://jsfiddle.net/adpro/5xbw80b1/
I have a link in the following div, it code is,
<?php _e('More', 'isis'); ?>
Now, I want to make the whole div a hyperlink. Please guide me. Thanks. The whole code is below,
<div class="midrow_blocks_wrap">
<i class="fa <?php echo of_get_option('block1_logo'); ?> fa-3x icon"></i>
<a href="#">
<div class="midrow_block">
<!--We need to make this div a link -->
<div class="mid_block_content">
<h3><?php echo of_get_option('block1_text'); ?></h3>
<p><?php echo of_get_option('block1_textarea'); ?></p>
</div>
<?php if ( of_get_option('block1_link') ) { ?><?php _e('More', 'isis'); ?><?php } ?>
</div>
</div>
<div class="shadow"><img src="<?php echo get_template_directory_uri(); ?>/images/service_shadow.png" alt="<?php the_title_attribute(); ?>" /></div>
</div>
A lot of the time when I'm trying to make a hyperlink fill a whole div I give the div a position: relative and the hyperlink a position: absolute; width: 100%; height: 100%; left: 0; top:0; I developed this because wrapping a whole div in a hyperlink can be screwy.
It is usually much easier to do it that way. If you give a z-index: 9 or some higher number you will cover most of your base for the div and then if you need other links or content in there you'll need to do a higher z-index.
Just a thought.
Use tag to show/hide div when click when JavaScript is disabled. Tried adjusting following example Show hide divs on click in HTML and CSS without jQuery but that doesn't seem to work.
From this question How to detect if JavaScript is disabled? i assumed that there isn't a convenient way to check if JS is disabled like:
if(JS is disabled){
// show <a> tag that words with jQuery to display div
} else {
// show label to show/hide div onclick
}
Any ideas will be welcomed.
Question How to make "a" tag to show a mini login form stored in "div" when JavaScript is disabled. Because when it's enabled it ?
Below is coresponding code of tag "a" and "div".
<ul class="nav nav-bar pull-right" >
<li class="dropdown" id="menuLogin">
<a class="dropdown-toggle" href="#" for="_1" data-toggle="dropdown" id="navLogin">Login</a>
<div class="dropdown-menu" style="padding-left:17px; left:-70px; width:200px;">
<?php
$form_sm = $this->form_sm;
$form_sm->prepare();
echo $this->form()->openTag($form_sm);
?>
<dl class="form">
<dd><?php
echo $this->formElement($form_sm->get('email'));
echo $this->formElementErrors($form_sm->get('email'));
?></dd>
<dd><?php
echo $this->formElement($form_sm->get('password'));
echo $this->formElementErrors($form_sm->get('password'));
?></dd>
<li class="divider" style="width:78%"></li>
<dd><?php
echo $this->formElement($form_sm->get('send'));
echo $this->formElementErrors($form_sm->get('send'));
?></dd>
<?php echo $this->form()->closeTag() ?>
</div>
</li>
</ul>
It uses a Bootstrap3 and Zend Framework components and by clicking "a" tag following line
<li class="dropdown" id="menuLogin">
change to
<li class="dropdown open" id="menuLogin">
You can use checkbox hack to do it. Since it is pure CSS there are some limitations. The elements you want to hide have to be siblings or children of the label you will use so you can select them when you get the :checked status. You can't go up to a element's parent in CSS.
Here is an example: http://jsfiddle.net/carloscalla/msaccf9w/
HTML:
<label class="hide_action" for="chk1">Action toggle</label>
<input id="chk1" type="checkbox" />
<div>Sibling div</div>
CSS:
.hide_action{
display:block;
background-color: yellow;
}
.hide_action + input{ /* or #chk1 */
display:none;
}
.hide_action + input + *{ /* or #chk1 (selector for what you want to hide) */
display:none;
}
.hide_action + input:checked + *{ /* or #chk1:checked (selector for what you want to hide) */
display:block;
}
You can not go up a parent and hide other element since you won't be able to get a selector for it. You can go down in children or siblings.
In this example I use + input to select the adyacent input to the label if you don't want them to be together you can identify it by an id as in the CSS comments.
When using Instagrams API to display the images on my website, the images aren't inheriting the containing divs style.
The style being float:left. So they don't stack on top of each other, they actually appear in rows and columns... rather than just a column.
The CSS:
#instagram.img {
float:left;
margin:10px;
}
The HTML/PHP (omitting get data & parsing) :
<div class="instagram">
<?php foreach ($result->data as $post): ?>
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?>
</div>
I tested that, images outside of the php adhere to the styling and they do. They float:left as expected.
Any help greatly appreciated.
.instagram {
float:left;
margin:10px;
display: inline-block;
}
As I said in the comment, # is the selector for id, . is the selector for class.
<div>
<?php foreach ($result->data as $post): ?>
<a class="group instagram" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?>
</div>
Add the .instagram class to your <a>, because adding it to your div will float the div left, and not the picture.
See display properties to see why the display: inline-block;.
Is there a way for me to highlight a menu li depending on the page id? I can't seem to figure out a way to do it.
http://www.dawaf.co.uk/cthm/work/
<div id="header">
<h1>
<a href="http://www.dawaf.co.uk/cthm/work">
<img src="http://www.dawaf.co.uk/cthm/wp-content/uploads/2013/01/logo2.png" alt="CTHM Logo" id="logo" width="140" height="44" />
</a>
<div id="contact-details">
26 Queen Anne Road, London, E9 7AH<br />
t + 44 7912325101<br />
hello#cthm.co.uk
</div>
</h1>
<div id="nav">
<span id="nav-li">
Work
Studio
CTHM+
<a href="https://twitter.com/hello_cthm" target="_blank">
<img src="http://www.dawaf.co.uk/cthm/wp-content/uploads/2013/01/twitter.png" alt="Twitter" width="13" height="13">
</a>
</span>
</div>
</div>
<div id="content">
I would recommend adding an active class to the navigation item. Something like this:
Work
And then the CSS:
#nav a.active {
/* your active style here */
}
You have two options. One is that mentioned by Zak, whereby you would need to use jQuery for your website to mark only one item at a time as "active". The other option is the CSS :active selector, which will auto apply CSS to the link which is in use (at the present time). For example:
#nav li a:active {
/* Insert styling here, such as, background-color: #01B */
}
Let me know if this helps!