Home › Forums › General Issues › css div different color for each line
Hello,
I work with your plugins
And I display information in my product sheet everything works well.
But I would like to stylize my divs and I would like to display this way but I can not do it
The goal is to have the same color all 2 divs
light Grey
dark gray
light Grey
dark gray
…
As in the image …
Can you help me? Gave me a way to get to that?
Thank you
This is really a basic php/html question. My suggestion would be to look at the first few results here https://www.google.com/search?q=html+php+alternate+colored+lines&ie=utf-8&oe=utf-8
Good evening,
I searched as you said I found the solution
But I have to adapt all my codes as I was otherwise doing for display.
However, there is one thing I can not do,
I have a title for my group
And when my group completes the title is displayed it’s normal
But I would like that when my group is empty, that the title is not displayed
echo '<h3 class="uppercase" data-text-color="primary"> MY GROUPE </h3>';
Can you help me?
Here is my final code
<?php
$group_ID = 30117;
$fields = array();
$fields = apply_filters('acf/field_group/get_fields', $fields, $group_ID);
if( $fields )
{
echo '<div class="row">';
echo '<div class="product-footer">';
echo '<div class="col large-12">';
echo '<h3 class="uppercase" data-text-color="primary"> MY GROUPE </h3>';
foreach( $fields as $field_name => $field )
{
if ($i % 2 != 0)
$rowColor = "#f2f2f2";
else
$rowColor = "#ffffff";
{
$value = get_field( $field['name'] );
if( $value && $value != 'no') {
echo '<div style="background:' . $rowColor . ';height:35px;width:100%;padding:5px 5px 5px 0px;">';
echo '<div style="width:40%;float:left;"><b>'. $field['label'] .'</b></div>';
echo '<div style="width:60%;float:left;">' . $value . '</div>';
echo '</div>';
$i++;
}
}
}
echo '</div>';
echo '</div>';
echo '</div>';
}
?>
thanks you
I did like that,
But I wonder if we can not do otherwise
Here’s my code, is there optimized?
if( get_field('pp_marque') ):
echo '<h3 class="uppercase" data-text-color="primary"> MY GROUPE </h3>';
endif;
thanks
No, that’s how you’d do it. See if the field has a value, display it if it does.
The topic ‘css div different color for each line’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.