I'm trying to figure out how I can use nth-child to make every other instance of a div with the class "mask" change color. I have a template code that loops over and over on a page. Here it is:
<div class="view">
<?php echo get_the_post_thumbnail( $post->ID, 'clip-thumb' ); ?>
<div class="mask">
<h2><?php the_title(); ?></h2>
<p>Your Text</p>
Read More
</div>
</div>
I want all the odd instances to be one color and all the even instances to be another. This was the code I was hoping would work:
.view .mask {
width: 326px;
height: 280px;
position: absolute;
overflow: hidden;
top: 0;
left: 0
}
.view .mask:nth-child(odd) {
background-color: rgba(235,167,32, 0.7);
}
.view .mask:nth-child(even) {
background-color: rgba(4,141,195, 0.7);
}
What ends up happening, though, is that all of the masks turn one background color (the even color). This can be seen here: http://noellesnotes.com/portfolio/seventeen/
Any direction would be greatly appreciated!
Each of your .mask elements are even, in the scope of their parent (.view):
<!-- First Child (odd) -->
<div class="view">
<!-- First Child (odd) -->
<?php echo get_the_post_thumbnail( $post->ID, 'clip-thumb' ); ?>
<!-- Second Child (even) -->
<div class="mask">
<h2><?php the_title(); ?></h2>
<p>Your Text</p>
Read More
</div>
</div>
<!-- Second Child (even) -->
<div class="view">
<!-- First Child (odd) -->
<?php echo get_the_post_thumbnail( $post->ID, 'clip-thumb' ); ?>
<!-- Second Child (even) -->
<div class="mask">
<h2><?php the_title(); ?></h2>
<p>Your Text</p>
Read More
</div>
</div>
To achieve what you're after, change the following:
.view .mask:nth-child(odd) {
background-color: rgba(235,167,32, 0.7);
}
.view .mask:nth-child(even) {
background-color: rgba(4,141,195, 0.7);
}
To:
.view:nth-child(odd) .mask {
background-color: rgba(235,167,32, 0.7);
}
.view:nth-child(even) .mask {
background-color: rgba(4,141,195, 0.7);
}
Related
I cannot for the life of me
figure out why my footer is showing up in the middle of my webpage. I have my #content div set to have a height of 100% and have given it a relative position; and I even added an absolute position to my footer with bottom: 0;. What am I missing? I can't figure out what is causing it to not follow the normal flow of elements in the page!
I've checked several posts with this same problem, but the suggestion is almost always what I've tried above. I did try getting rid of the position for #content and the footer and instead setting display: inline-block; for both (was suggested in another post), and that didn't do anything.
Link to my in-progress page: http://freshcardsite.thewelllovedlife.com/home-use/
HTML for the Page (starting below the header):
<div class="site-content-contain">
<div id="content" class="site-content">
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main consumer-page" role="main">
<?php
// vars
$topsection = get_field('consumer_top_image_section');
if( $topsection ): ?>
<div class="top-image" style="background-image: url(<?php echo $topsection['consumer_background_image']; ?>); background-size: cover; background-repeat: no-repeat; background-position: bottom center;">
<div class="top-section">
<div class="top-text">
<h1>Fresh Card</h1>
<p><?php echo $topsection['consumer_top_content']; ?></p>
<img src="<?php echo $topsection['consumer_top_icon']; ?>" />
</div>
</div>
</div>
<?php endif; ?>
<?php
// vars
$aboutsection = get_field('consumer_about_section');
if( $aboutsection ): ?>
<div class="about-section">
<div class="about-content">
<h2><?php echo $aboutsection['consumer_about_section_title']; ?></h2>
<p><?php echo $aboutsection['consumer_about_section_main_content']; ?></p>
</div>
<?php if($aboutsection['consumer_uses_section'] ): ?>
<div id="tabs">
<ul class="tabs">
<?php foreach($aboutsection['consumer_uses_section'] as $use): ?>
<li><h3><?php echo $use['consumer_use_name']; ?></h3><img src="<?php echo $use['consumer_use_icon']; ?>" /></li>
<?php endforeach; ?>
</ul>
<?php foreach($aboutsection['consumer_uses_section'] as $use): ?>
<div id="<?php echo $use['consumer_use_number']; ?>">
<p> <?php echo $use['consumer_use_information']; ?> </p>
<p> <?php echo $use['consumer_use_video']; ?</p>
<p> <?php echo
$use['consumer_second_use_video']; ?> </p>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="contact-section">
<div class="contact-content">
<h2>Contact Us</h2>
<?php the_field('consumer_contact_section'); ?>
</div>
</div>
<?php if (have_posts() ) : ?>
<div class="news-section">
<div class="news-content">
<h2>Awards & News</h2>
<ul>
<?php $the_query = new WP_Query( 'posts_per_page=5' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?>
</a></li>
<li><?php the_excerpt(__('(more…)')); ?></li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
</div>
</div>
<?php else : ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
</div><!-- #content -->
<footer id="colophon" class="site-footer" role="contentinfo">
<div class="wrap">
<?php
get_template_part( 'template-parts/footer/footer', 'widgets' );
if ( has_nav_menu( 'social' ) ) : ?>
<nav class="social-navigation" role="navigation" aria-label="
<?php esc_attr_e( 'Footer Social Links Menu', 'twentyseventeen' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'social',
'menu_class' => 'social-links-menu',
'depth' => 1,
'link_before' => '<span class="screen-reader-text">',
'link_after' => '</span>' . twentyseventeen_get_svg( array( 'icon' => 'chain' ) ),
) );
?>
</nav><!-- .social-navigation -->
<?php endif;
get_template_part( 'template-parts/footer/site', 'info' );
?>
</div><!-- .wrap -->
</footer><!-- #colophon -->
</div><!-- .site-content-contain -->
</div><!-- #page -->
And here's my relevant CSS
html, body {
height: 100%;
}
.consumer-page {
min-width: 100%;
margin: 0 auto;
position: absolute;
left: 0;
top: 0;
}
#content {
position: relative;
height: 100%;
min-height: 100%;
}
footer#colophon {
position: absolute;
bottom: 0;
}
Your main problem is that .consumer-page is getting a position:absolute and its messing with your elements heights
Lets try the next classes:
.consumer-page {
min-width: 100%;
margin: 0 auto;
position: initial;
left: 0;
top: 0;
}
.wrap {
padding: 0;
width: 100vw;
max-width: 100vw;
margin: 0;
}
#content {
padding: 0;
}
footer#colophon {
position: initial;
bottom: 0;
}
Hope this helps. If you run into problems, pliss coment on this answer and will happily edit
I'm not sure why this is, but my wordpress post isn't actually nested inside the div that the PHP code is nested in.
Here is the code on the html side:
<!-- BLOG -->
<div class="blog" id="blog">
<div class="wrap">
<div class="col-sm-12">
<?php
$args = array( 'numberposts' => 1, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
echo '<section id="latest_posts">';
foreach ($postslist as $post) : setup_postdata($post); ?>
<h2><?php the_date(); ?></h2>
<h2> <?php the_title(); ?></h1>
<?php endforeach; ?>
<p><?php the_content();?></p>
</section>
</div>
</div>
</div>
And here is the only CSS affecting this code:
/* BLOG */
.blog {
background-image: url("../images/pat_1_bg.png");
padding-top: 60px;
padding-bottom: 60px;
height: 100%;
}
Any idea why this would be sitting outside of the div? It's almost like it has a positive z-index, which it doesn't. I can change the height of 'blog' as much as I want, and it will indeed affect the height of the div, but the post content is unaffected.
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 7 years ago.
Improve this question
I'm facing logo and menu bar alignment no my website.
how can i fix it? sharing images below.
I want to make changes as below image..
What HTML or CSS code that I should Write ?
Continuing our discussion from wordpress.stackexchange.com here and here, if I get it right, what you are trying to do is having the same menu you have when you resize the browser's window size to 1180px, where the logo goes to the center, but instead of having this only when you resize the window to 1180px, you want to have this type of disposal at all time, meaning having the 1180px menu as the site's default menu.
First
So in order to do this, we need to remove the current CSS for the default menu when the screen size is bigger than > 1180px. To do this, go to - style.css:1006 (meaning go to the file style.css line 1006), and remove the following CSS:
Absolute path for this file - http://www.norenge.com/wp-content/themes/accesspress-store/style.css
#site-branding {
width: 20%;
padding-bottom: 5px;
min-height: 60px;
}
Second
Next thing we need to set the style for the menu when it gets at 1180px as the new default menu. In order to do this, go to: - responsive.css:48, an remove the media queries around the code, which currently the code it's something like this:
Absolute path for this file - http://www.norenge.com/wp-content/themes/accesspress-store/css/responsive.css?ver=4.3.1
#media (max-width: 1180px) {
#site-branding {
float: none;
display: inline-block;
text-align: center;
padding-bottom: 5px;
max-width: 320px;
width: 100%;
}
}
And you need to remove the #media query or just put the code outside the #media query, to be only like this:
#site-branding {
float: none;
display: inline-block;
text-align: center;
padding-bottom: 5px;
max-width: 320px;
width: 100%;
}
Third and last
At last, fix the menu centering disposal, go to - style.css:4328 and remove the float:right; property from the id #menu:
Absolute path for this file - http://www.norenge.com/wp-content/themes/accesspress-store/style.css
#menu {
float: right; /* <- REMOVE THIS LINE */
position: relative;
height: 100%;
}
With this being done, the supposed menu from the size 1180px will now become the main default menu. Good luck! :)
Use this CSS for the logo:
.site-logo {
position: absolute;
top:-55px;
left:50%;
margin-left: -150px;
}
You'll want to move the following HTML,
<a class="site-logo" href="http://www.norenge.com/">
<img src="http://www.norenge.com/wp-content/uploads/2015/11/Oranemart-accesspress_store-logo.png" alt="Capital's First Online Super Store">
</a>
to be an immediate descendant of the <section class="home_navigation" element. Then apply text-align: center; to that same section element and it achieves the look you're asking for.
<?php
/**
* The header for our theme.
*
* Displays all of the <head> section and everything up till <div id="content">
*
* #package AccessPress Store
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="mastheads" class="site-header" role="banner">
<?php if (as_before_top_header_enabled()): ?>
<div class="before-top-header">
<div class="ak-container clearfix">
<?php accesspress_ticker_header_customizer(); ?>
<?php
if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
?>
<div class="welcome-user">
<span class="line">|</span>
<?php _e('Welcome ', 'accesspress-store'); ?>
<a href="<?php echo get_permalink(get_option('woocommerce_myaccount_page_id')); ?>" class="my-account">
<span class="user-name">
<?php echo $current_user->display_name; ?>
</span>
</a>
<?php _e('!', 'accesspress-store'); ?>
</div>
<?php }
?>
<?php if (is_active_sidebar('header-callto-action')): ?>
<div class="header-callto">
<?php dynamic_sidebar('header-callto-action') ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="top-header clearfix">
<div class="ak-container clearfix">
<!-- Cart Link -->
<?php
if (is_woocommerce_activated()):
echo accesspress_wcmenucart();
endif;
?>
<?php
if (function_exists('YITH_WCWL')) {
$wishlist_url = YITH_WCWL()->get_wishlist_url();
?>
<a class="quick-wishlist" href="<?php echo $wishlist_url; ?>" title="Wishlist">
<i class="fa fa-heart"></i>
<?php echo "(" . yith_wcwl_count_products() . ")"; ?>
</a>
<?php
}
?>
<div class="login-woocommerce">
<?php
if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
?>
<a href="<?php echo wp_logout_url( home_url() ); ?>" class="logout">
<?php _e(' LogOut', 'accesspress-store'); ?>
</a>
<?php
} else {
?>
<a href="<?php echo get_permalink(get_option('woocommerce_myaccount_page_id')); ?>" class="account">
<?php _e('LogIn', 'accesspress-store'); ?>
</a>
<?php }
?>
</div>
<!-- if enabled from customizer -->
<?php if (!get_theme_mod('hide_header_product_search')) { ?>
<div class="search-form">
<?php get_search_form(); ?>
</div>
<?php } ?>
</div>
</div>
<section class="home_navigation">
<div class="inner_home">
<div class="ak-container clearfix">
<div id="site-branding" class="clearfix">
<?php accesspress_store_admin_header_image() ?>
</div><!-- .site-branding -->
<div class="right-header-main clearfix">
<div class="right-header clearfix">
<!-- if enabled from customizer -->
<div id="toggle">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
<div class="clearfix"></div>
<div id="menu">
<?php
if (is_page('checkout') && get_theme_mod('hide_navigation_checkout')) {
} else {
?>
<nav id="site-navigation" class="main-navigation" role="navigation">
<a class="menu-toggle">
<?php _e('Menu', 'accesspress-store'); ?>
</a>
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container_class' => 'store-menu',
'fallback_cb' => 'custom_fallback_menu',
)
);
?>
</nav><!-- #site-navigation -->
<?php } ?>
</div>
</div> <!-- right-header -->
</div> <!-- right-header-main -->
</div>
</div>
</section><!--Home Navigation-->
</header><!-- #masthead -->
<div id="content" class="site-content">
>> this is my header.php code
first of all, I found that Question here but the answer won't quite fit in my case, which is why I ask a question, that may seem similar but isn't. If that makes sense somehow :-D
I'm creating a childtheme to the "responsive"-Wordpresstheme from cyberchimps.
For that I needed text to shape in 3 columns, but also to be editable in the backend of the Site. I managed that with CCS:
.col-940{
clear: none;
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-webkit-column-gap: 40px;
-moz-column-count: 3; /* Firefox */
-moz-column-gap: 40px;
column-count: 3;
column-gap: 40px;
}
p {
margin: 5px 0px 0px 0px;
}
That now generates the problem, that the first column starts 5px lower than the following ones. I can't figure out why.
As said above the answer in the other thread will not work, because I also have sub-sites that only use 2 columns, which is why I can't use a defined width.
Above/before the div the text is in there always is just another div.
(PHP)container the text is in:
<?php if( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>
<?php responsive_entry_before(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php responsive_entry_top(); ?>
<div class="post-entry">
<?php the_content( __( 'Read more ›', 'responsive' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="pagination">' . __( 'Pages:', 'responsive' ), 'after' => '</div>' ) ); ?>
</div>
<!-- end of .post-entry -->
<?php responsive_entry_bottom(); ?>
</div><!-- end of #post-<?php the_ID(); ?> -->
<?php
endwhile;
get_template_part( 'loop-nav' );
else :
get_template_part( 'loop-no-posts' );
endif;
?>
(HTML)container as produced by the PHP:
<div id="post-25" class="post-25 page type-page status-publish hentry">
<!--
<h1 class="entry-title post-title">Kontakt</h1>…
-->
<div class="post-entry">
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing …
</p>
</div>
<!-- end of .post-entry -->
</div>
<!--end of #post-25 -->
Screens:
Shot of the Situation
Shot with marked problem
You have applied 5px margin-top and the only place that occurs at the top of a column is at the start of the first one. You need to remove this margin-top, perhaps with
.post-entry > p:first-child {
margin: 0;
}
For me, I needed each item in the column to have a fixed height. It also had problems with vertical alignement. I was able to fix the vertical alignment by having a line-height on the item be the desired height of the item and wrapping the content of the item inside a div.
ul {
column-count: 2;
}
ul > li {
line-height: 30px;
}
ul > li > div {
height: 30px;
line-height: 1.2;
}
I need a table layout that looks like the following:
Cell one (rowspan 2)
Cell two and three (next to cell one and each other)
Cell four (colspan 2 underneath cell two and three)
The problem I am having though is that it needs to be done using CSS only, I can't use any table elements in the Code at all.
Cell 1 also needs to still stretch to a 100% width if Cell 2, 3 and 4 are empty.
I am working on an Artisteer 4 Template in Joomla and have searched all over and just can't get to a working solution.
The code I have is as follows:
<div class="prof-layout-wrapper">
<div class="prof-content-layout">
<div class="prof-content-layout-row">
<div class="prof-layout-cell prof-content">
<?php
echo $view->position('banner2', 'prof-nostyle');
if ($view->containsModules('breadcrumb'))
echo artxPost($view->position('breadcrumb'));
echo $view->positions(array('user1' => 50, 'user2' => 50), 'prof-article');
echo $view->position('banner3', 'prof-nostyle');
echo artxPost(array('content' => '<jdoc:include type="message" />', 'classes' => ' prof-m essages'));
echo '<jdoc:include type="component" />';
echo $view->position('banner4', 'prof-nostyle');
echo $view->positions(array('user4' => 50, 'user5' => 50), 'prof-article');
echo $view->position('banner5', 'prof-nostyle');?>
</div>
<?php if ($view->containsModules('left')) : ?>
<div class="prof-layout-cell prof-sidebar1">
<?php echo $view->position('left', 'prof-block'); ?>
</div>
<?php endif; ?>
<?php if ($view->containsModules('right')) : ?>
<div class="prof-layout-cell prof-sidebar2">
<?php echo $view->position('right', 'prof-block'); ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
The css is:
.prof-layout-wrapper
{
position: relative;
margin: 0 auto 0 auto;
z-index: auto !important;
}
.prof-content-layout
{
display: table;
width: 100%;
table-layout: fixed;
float: left;
}
.prof-content-layout-row
{
display: table-row;
}
.prof-layout-cell
{
display: table-cell;
vertical-align: top;
}
For the life of me I can't get Cell 4 to span accross without destroying the entire layout.
Please help!
(I hope this is a good enough explanation)
Sure!
Demo Fiddle
HTML
<div class='table'>
<div class='row'>
<div class='cell'>cell1</div>
<div class='cell'>
<div class='table'>
<div class='row'>
<div class='cell'>cell2</div>
<div class='cell'>cell3</div>
</div>
<div class='caption'>cell4</div>
</div>
</div>
</div>
</div>
CSS
html, body {
width:100%;
}
.table {
display:table;
width:100%;
}
.row {
display:table-row;
}
.cell {
display:table-cell;
border:1px solid grey;
}
.caption {
display:table-caption;
caption-side:bottom;
border:1px solid grey;
}
If you want the auto expanding/collapse functionality, you can tweak the code slightly, a la this fiddle