Home › Forums › ACF PRO › Flexible Content, Help Creating Dynamic Script to Detect Adjacent Flex Content › Reply To: Flexible Content, Help Creating Dynamic Script to Detect Adjacent Flex Content
I think that your question “Why not just decrease the margin using CSS?… is a valid one.
If these text blocks are stacked on top of each other this can easily be solved using CSS, although it may require adjustments to other CSS. In this case I would use a top margin instead of a bottom margin and then.
/* assuming your container has a class of "text_block" */
.text_block+.text_block {
margin-top: 0;
}
To do it the way you’re doing it, before applying the margin bottom of 0 you also need to look at the next element of your array. If it is not a text-block as well then do not apply the margin bottom of 0. I don’t know much about array_search, but you would check here I think.
if($after == 'text_block') {
// check to see if the next block is a text block
// if it is then do not apply these classes
echo '<div id="text-block" class="text-center mt-5 mb-0 text-after">';
} else {
echo '<div id="text-block" class="text-center my-5">';
}
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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.