Any advice on how to horizontally center my css slideshow?

After using jsfiddle for the file, I encountered an issue with centering the slideshow at the bottom. Despite my efforts, it remains aligned to the left margin. Check out the end results here: https://jsfiddle.net/n6kae2rn/ https://jsfiddle.net/n6kae2rn/embedded/result/

.css-slideshow {
    text-align:center;
    position: relative;
    max-width: 410px;
    height: 730px;
}
.css-slideshow figure {
    margin: 0;
    position: absolute;
}
.css-slideshow figcaption {
    position: absolute;
    top: 0;
    color: #fff;
    background: rgba(0, 0, 0, .3);
    font-size: .8em;
    padding: 8px 12px;
    opacity: 0;
    transition: opacity .5s;
}
.css-slideshow:hover figure figcaption {
    transition: opacity .5s;
    opacity: 1;
}
.css-slideshow figure {
    opacity:0;
}
figure:nth-child(1) {
    animation: xfade 42s 32s infinite;
}
figure:nth-child(2) {
    animation: xfade 48s 24s infinite;
}
figure:nth-child(3) {
    animation: xfade 48s 16s infinite;
}
figure:nth-child(4) {
    animation: xfade 48s 8s infinite;
}
figure:nth-child(5) {
    animation: xfade 48s 0s infinite;
}
@keyframes xfade {
    0% {
        opacity: 1;
    }
    10.5% {
        opacity:1;
    }
    20% {
        opacity: 0;
    }
    98% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
}
div.poster {
    background: url(http://jillun.com/dp-intsmall.jpg) repeat;
    padding: 25px;
}

Answer №1

To enhance your webpage, insert

<div class="css-container">
above the
<div class="css-slideshow">
. Remember to include another </div> after the css-slideshow div.

Next, update your CSS with these changes:

.css-slideshow {
text-align:center;
position: relative;
max-width: 410px;
height: 730px;
margin: auto;
}
.css-container {
width: 100%;
}

This adjustment establishes a full width container element on your page. The slideshow CSS configuration aligns elements to the center and automatically fills in margins.

Give it a try and see how it improves your layout!

Check out the JSFiddle demo here

Answer №2

Have you attempted adding the CSS property margin : 0 auto; to the css-slideshow class?

Remember, it's essential to ensure that your images are of equal width. If they differ in width, even if the css-slideshow is centered, wider images will appear further to the right.

.css-slideshow {
  text-align: center;
  position: relative;
  max-width: 410px;
  height: 730px;
  margin: 0 auto;
}
.css-slideshow figure {
  margin: 0;
  position: absolute;
}
<!-- Rest of the CSS code as provided -->
<title>Highlander: Dark Places Interview Andrew Modeen</title>

<body>
 <!-- More content related to the interview and film production -->
 <div class="poster">
    <!-- Poster details here -->
 </div>
 <div class="fade">
    <!-- Fade effect details -->
 </div>
</body>

</html>

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

What is a way to center content vertically without using extra containers?

I've been facing challenges in vertically aligning an item within its container. Despite trying multiple suggestions that advise wrapping the content in another div or container, I encountered various issues which I won't delve into. Therefore, ...

trigger a function when the iframe is altered

I am currently working on creating a function that can process credit card payments using an iframe. The challenge I am facing at the moment is dealing with error messages appearing in a less than ideal manner. Photo: I have been attempting to capture the ...

Issues with Adaptive Headers

* { box-sizing: border-box; font-family: sans-serif; margin: 0; padding: 0; } html, body { font-size: 14px; } header { width: 100vw; height: 50px; background-color: #222; margin: 0 auto; padding: 0; display: flex; justify-content: ...

Overflowing dropdown menus on a dynamic navigation bar

After creating a navigation bar with dropdown links, I encountered an issue where hovering over the link to open the drop-down caused it to overflow to the right. Since the button is positioned at the right end of the navbar, it resulted in the scrollbar a ...

Tips for seamlessly incorporating advertisements into a mixed application

I am having trouble adding banner ads to my hybrid application developed with Telerik. Despite my extensive research, I have been unable to find a suitable solution. Is there any html5 or javascript banner advertising service/API that is compatible with ...

Display or conceal headers depending on the corresponding homepage using Vue.js

I currently have a header-one that appears on all pages by default. Additionally, there are header-two and header-three which only appear when their respective home pages are visited. Is there a way to conditionally show header-v1 if the path is '/hom ...

The process of toggling a div to slide up and down explained

I'm attempting to create a slide toggle effect on a hidden DIV when a user hovers over specific link buttons. JavaScript: $(function () { // DOM ready shorthand var $content = $(".sliderText"); var $contentdiv = $(".sliderCo ...

Clearly define where each navigation bar item should be displayed within your Django application using Bootstrap

I've been attempting to specify the exact page where this navbar dropdown should be displayed. I attempted adding this line: {% if request.resolver_match.url_name == 'club_selection' %} class = "active" {% endif %} but it doesn&ap ...

The iPhone header position switches when an HTML5 input type number is selected

I am currently working on a project that involves jQuery Mobile and PhoneGap. One issue I am encountering is when using the iPhone version, the header position changes when I click on an input type number. NOTE: When I focus on the input type number in my ...

When accessing the innerHTML and outerHTML properties on an HTMLElement, they may return undefined without triggering

Task: My goal is to take an HTML string, make changes to certain attributes of image tags within it, and then return the modified HTML string. The function I have developed follows these steps: private resolveImagesInHTML (body: string): string { le ...

jQuery-powered unique serial numbers for tables

I've encountered an issue with my dynamic table that consists of 2 dynamic rows including students, their subjects, and marks. The code in question is provided below: Feel free to check out the code here Snippet for Serial Number function gene ...

Adjust the styling with jQuery according to the selected value from the dropdown menu

Check out this Fiddle I have a jQuery script that is supposed to change the style of an input box to display:block if the selected value is "<>" (Between). However, currently it is changing the css for all selected items instead of just the target i ...

Avoid displaying the HTML formatting whitespace on the webpage

I'm working with cakephp's helper to generate spans using the code below: <div id="numberRow"> <?php echo $this->Paginator->numbers(array('class' => 'numbers', 'separator' => '', & ...

Is it possible to design and implement Materialize CSS inputs without relying on Materialize CSS?'

Is there a method to implement Materialize CSS input elements that include placeholders and icons without directly using the Materialize CSS framework? I prefer not to mix frameworks in order to avoid potential conflicts, as I am already utilizing anothe ...

How to make a div in Javascript smoothly slide out when it appears

Looking to add some smooth sliding animation to this basic JS code instead of the glitchy appearance it currently has. I've experimented with different options but haven't had any success, any suggestions? Here's the code snippet along with ...

Error: The EJS compiler encountered a SyntaxError due to an unexpected token || in the show component file located at /var/www/html

I'm currently working on a project inspired by Colt Steele's YelpCamp creation during his Udemy Web Dev Bootcamp. Everything was going smoothly until I tried to refactor some code towards the end of the course using YouTube tutorials. Now, whenev ...

The display and concealment of a div will shift positions based on the sequence in which its associated buttons are clicked

I am in need of assistance with coding (I am still learning, so please excuse any syntax errors). What I am trying to achieve is having two buttons (button A and button B) that can toggle the visibility of their respective divs (div A and div B), which sh ...

A guide on manipulating an input field to trigger md-datepicker upon clicking

What is the best way to convert an input text into a fire md-datepicker and achieve a similar result like this? ...

creating nested columns within a parent column using flexbox techniques

Struggling with column height issues in Bootstrap 3? Consider using flexboxes for a simpler solution. Check out the design image I created using Bootstrap 3: Can this design be replicated with flexboxes? I have successfully implemented flexboxes for the m ...

How can JavaScript onClick function receive both the name and value?

My current challenge involves a function designed to disable a group of checkboxes if they are not checked. Originally, this function was set to work onClick(), with one argument being passed from the checkbox element. Now, I need this function to be trigg ...