Flexslider optimized for mobile devices

I am currently using the Sparkling theme on a Wordpress website. This particular theme utilizes Flexslider within a div at the top of the page. Each slide featured in the slider includes an image, as well as a div containing a post title and excerpt.

The slider is constructed within header.php through this function:

function sparkling_featured_slider() {
   if ( is_front_page() && of_get_option( 'sparkling_slider_checkbox' ) == 1 ) {
      echo '<div class="flexslider">';
         echo '<ul class="slides">';
            $count = of_get_option( 'sparkling_slide_number' );
            $slidecat =of_get_option( 'sparkling_slide_categories' );

            $query = new WP_Query( array( 'cat' =>$slidecat,'posts_per_page' =>$count ) );
            if ($query->have_posts()) :
               while ($query->have_posts()) : $query->the_post();

               echo '<li>';
               if ( (function_exists( 'has_post_thumbnail' )) && ( has_post_thumbnail() ) ) :
                 echo get_the_post_thumbnail();
               endif;

               echo '<div class="flex-caption">';
                  if ( get_the_title() != '' ) echo '<h2 class="entry-title">'. get_the_title().'</h2>';
                  if ( get_the_excerpt() != '' ) echo '<div class="excerpt">' . get_the_excerpt() .'</div>';
              echo '</div>';
          echo '</li>';
          endwhile;
        endif;

  echo '</ul>';

echo ' </div>';

} } endif;

The resulting HTML appears as follows:

<div class="top-section">
    <div class="flexslider">
        <ul class="slides">
            <li>
                <img width="1920" height="512" src="http://pathtoslider.jpeg" 
                    class="attachment-post-thumbnail size-post-thumbnail wp-post-image" 
                    alt="slide1" 
                    srcset="pathstodifferentresolutions.jpg" 
                    sizes="(max-width: 1920px) 100vw, 1920px" />
                <div class="flex-caption">
                    <h2 class="entry-title">Tomatoes</h2>
                    <div class="excerpt">Knowledge is knowing that tomatoes are a fruit. Wisdom is knowing not to put them in a fruit salad.</div>
                    </div>
                </li>
                ..more slides..
        </ul>
    </div>
</div>

<div class="container main-content-area">

Usually, the flex-caption is hidden on smaller screens with a display:none setting in a media query, but I want it visible, so I changed the display property to inline in my custom media query.

This adjustment brings about another issue because the top-section div ends up being the same height as the image, potentially not leaving enough room for the flex-caption.

To address this, I aim for the bottom of the entry-title to align with the bottom of the image, and have the excerpt displayed right below the image, achieving this with the following code:

@media (max-width: 768px) {
  .flex-caption {
    display: inline;
    bottom: 0;
   }
  .entry-title {
    position: absolute;
    bottom: 0;
  }
  .excerpt {
    position: absolute;
    vertical-align: top;
  }
}

Unfortunately, this does not resize the top-section div, leading me to override the main-content-area.

I've experimented with various solutions, including attempting to use height:auto in different places without success.

I am struggling to determine how the slider's height is determined. Could it be related to get_the_post_thumbnail? This remains unclear to me.

Answer №1

One potential solution is to adjust the image height within the functions.php file using the following code snippet:

function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' )
.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The element's height of 100% falls short of reaching the bottom of its containing element

I have searched through numerous questions, but I am unable to find a solution. Could someone kindly check this link and help me understand why the sidebar is not reaching the bottom of the content div: Using Javascript is not an option for me in this cas ...

CSRF validation did not pass. The request has been cancelled. The failure occurred due to either a missing or incorrect CSRF token

Upon hitting the submit button in the login form, I encountered the following error message: Forbidden (403) CSRF verification failed. Request aborted. CSRF token missing or incorrect. settings.py MIDDLEWARE = [ 'django.middleware.security.Secur ...

Adding text on top of images for optimal mobile viewing

I'm struggling to ensure that the text stays contained next to the image. It's working fine on desktop and tablet, but I'm facing challenges with mobile. While I have managed to improve it slightly, I can't figure out what exactly I am ...

What is the process for removing the highlighted border from a navigation menu in ASP.NET?

I am currently utilizing the navigation menu in the ASP.NET toolbox, but I am struggling to remove an unwanted golden border. Despite my efforts, I have not been able to find any information on how to resolve this issue. The golden border only appears when ...

Achieving a centered Title while aligning Nav all the way to the right using flexbox: tips and tricks

I am currently using flexbox to align the h1 and nav on the same line with display:flex. I want the title to be centered and the navigation to be on the right side. However, I am struggling to figure out how to move the navigation all the way to the right. ...

Conditionals in Angular 2 using Sass

Looking to apply this style with Sass or CSS: IF :host.form-control MATCHES .ng-valid[required] OR .ng-valid.required THEN :host ::ng-deep input.form-control = border-left: 5px solid #42A948; Appreciate the help! ...

To ensure responsiveness in JavaScript, adjust the width to 100%

Recently, I came across this piece of code: <div style="text-align:center; max-width:500px; width:100%; margin:auto"> <script type="text/javascript" src="transition_example.js"></script></div> Here is the content of transition ...

Top approach for creating/previewing a website using PHP, CSS, and MYSQL

When creating a website that will eventually be hosted on a remote server, what is the most effective way to code and test? Here are some examples of what I mean: - Develop locally on your computer and access files from there. Should libraries and databa ...

What is the best way to center these icons vertically in my navigation menu using CSS?

My website has a navigation menu with third-party icon libraries (Material/FontAwesome) in use. I am facing an issue where the icons are not aligning vertically with the anchor text. Adjusting the font size of the icon to match the text results in it appe ...

Issue with Angular 6: Animation with LESS is failing to work post deployment

Hello everyone, I'm facing an issue with my LESS animation. When I deploy my app on the server after using ng build --prod, the CSS animations are not visible in browsers. They work perfectly fine on localhost but fail to work after deployment and I c ...

Issue with Email Signature on replies

Recently, I had some email signatures designed and they appear great when sent out, but encounter issues upon receipt or reply: The logo gets distorted and occasionally enlarges significantly during replies. The font color switches to black when receivin ...

How can I line up elements in different divs when the width is adjusting based on the window size?

Trying to align a search input and a result element in separate containers when the window size changes. Looking for a solution without using Javascript. One window size: https://i.sstatic.net/LiQtY.png A smaller window: https://i.sstatic.net/dgj4I.png C ...

Tips for concealing boostrap spinners

Within the main component, I have an @Input() alkatreszList$!: Observable<any[]>; that gets passed into the child component input as @Input() item: any; using the item object: <div class="container-fluid"> <div class="row ...

Utilizing cookies to track the read status of articles - markers for reference

Currently, I am in the process of developing a website and am interested in implementing a feature that allows users to track which articles they have read. I am considering adding a small circle next to each article heading to signify whether it has been ...

Update the text on the Bootstrap modal label before it is clicked

I am currently working on implementing a Bootstrap modal with a label control. The modal is triggered by clicking a button, and I am facing an issue where I need to change the text of the label before the modal launches. However, the text that is supposed ...

The Mat-paginator is refusing to align to the right edge when scrolling the table horizontally in an Angular application

Overview: My Angular component features a table with Angular Material's mat-table and paginator. Despite fetching data from a source, the paginator fails to float right when I scroll horizontally. Sample Code: <!-- Insert your code snippet below ...

Incorporating React's dynamic DIV layout algorithm to generate a nested box view design

My goal is to showcase a data model representation on a webpage, depicting objects, attributes, and child objects in a parent-child hierarchy. I had the idea of developing a versatile React component that can store a single data object while also allowing ...

Automating testing for numbered lists with CSS list-style-type decimal

I need help with a JavaScript and CSS project. I have a situation where I have a numbered list like this: Coffee Tea Cola Here is the code structure I am using: <!DOCTYPE html> <html> <head> <style> ul.a {list-style-type ...

Concealing divisions on a website with CSS styling

In my div, I have some text that I want to hide. <div style='visibility:hidden;' id='emailid'>$email</div> Although the visibility attribute successfully hides the text, it leaves behind empty space on the webpage where th ...

Steps for modifying material-ui timepicker to display time in a 24-hour format

Presently, I am utilizing a Timepicker from material-ui. It is currently configured with type="time", allowing me to select times throughout the day in 12-hour increments with an AM / PM choice. However, I wish to adjust my picker to a 24-hour format, elim ...