Align text vertically in a responsive absolutely-positioned div using CSS

Is there a way to horizontally center text inside a responsive div without relying on new CSS3 tricks?

Check out this fiddle for reference: http://jsfiddle.net/M8rwn/

.iosSlider {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
}
/* slider */
.iosSlider .Slider {
    width: 100%;
    height: 100%;
}
/* slide */
.iosSlider .Slider .Slide {
    float: left;
    width: 100%;
}
.iosSlider .Slider .Slide img{
    width: 100%;
    height: auto;
} 
.slider-prevContainer {
    position: absolute;
    top: 0;
    left: 10px;
    width: 50px;
    height: 50%;
    color: #595e62;
    text-align: center;
}
.slider-nextContainer {
    position: absolute;
    top: 0;
    right: 0;
    width: 50px;
    height: 100%;
    opacity: 1;
    color: #595e62;
    background: blue;
}
.slider-next {
    position:absolute;
    height: 50%;
    width: 100%;
    top: 25%;
    text-align: center;
    vertical-align: middle;
    background: red;
    box-sizing: border-box;
    font-size: 50px;
}

#single-slider {
    float: left;
    width: 500px;
    height: 500px;
    min-width: 0;
    margin: 0;
    border: none;
    background: #000;
} 

Answer №1

Alright, I believe I have found a resolution.

Modified HTML:

<div class="slider-next">
   <div id='slider-next-inner'>
      >
   </div>
</div>

CSS Update:

#slider-next-inner{
   position:relative;
   top:50%;
   margin-top:-30px;
   /* The margin-top is half the height of the element (currently 59px) */
}

Check out the link here: http://jsfiddle.net/M8rwn/18/

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

Prevent parent element from triggering double click when double clicking on children element with CSS or jQuery

Check out my project demo here Whenever I double click on a child element, it also triggers the parent element at the same time. I want to prevent this behavior so that only the child element is affected by the double click event. Can anyone provide assis ...

in Vue.js, extract the style of an element and apply it to a different element

Currently, I am using VUE.js 2 in my project. Here is my website's DOM structure: <aside :style="{height : height()}" class="col-sm-4 col-md-3 col-lg-3">...</aside> <main class="col-sm-8 col-md-9 col-lg-9" ref="userPanelMainContents" ...

Using AngularJS to handle click events and blur events

I am attempting to dynamically change the class based on user interaction in my code. The class should switch between "large" and "active" depending on whether the input field is filled or not. Please see the modified script below. <div class="snippe ...

Adjust the top spacing in relation to the paragraph tag using jQuery

I wish to create multiple div elements with nested p tags that are initially hidden. Upon hovering over each div, I want the corresponding p tag to move up by the negative value of its own height. For instance: The first p tag has a height of 60px and a m ...

What is the best way to close all other accordion tabs when selecting one?

A simple HTML code was created with the full pen accessible here. <div class="center"> <div class="menu"> <div class="item"> <button class="accordionBtn"><i class=&q ...

Tips for keeping the hover effect of a sibling element in Material-UI

Card Component import image from "../../Assets/pic.jpg"; import React, { useState } from "react"; import { makeStyles } from "@material-ui/core/styles"; import Card from "@material-ui/core/Card"; import CardActionAre ...

Customizable form with dynamic content and interactive button within a set location

One distinct challenge not addressed in the similar inquiries below relates to a FORM component with both a variable segment and a fixed footer for submit buttons. The objective is to present: A header (a table set to 100% width including a logo and tex ...

Learn the simple technique for transferring text to the clipboard using the data-title attribute

Hey there, I need some help with the following code snippet: <h3 class="project discord" data-title="test1234"><i class='bx bx-fw bx-tada-hover bxl-discord-alt'></i>Discord</h3> I want to be able to c ...

How to position images in the center horizontally using CSS without using percentage (%) measurements

There seems to be some excess space on the right side of my gallery... The container for my images: .my-gallery figure { display: block; float: left; width: 150px; } Is it possible to always horizontally center images on different screen sizes wit ...

Issue with utilizing display: table and overflow: hidden in Internet Explorer and Firefox, functioning properly on Webkit and Blink

JSFiddle : http://jsfiddle.net/h7xvr2t9/2/ I have been experimenting with ways to achieve some effects: Animating a hidden DIV to slide into view from below a visible container Centering text/image on a link to trigger the animation HTML <div clas ...

Style large and small text side by side with CSS styling

I've been trying to figure out how to position a smaller biography-style text next to this large title, but I'm having trouble finding a solution. I've experimented with float: left, float: right, and display: flex in my CSS code. Below is t ...

Show the Canvas element at the back of the DIV

This particular question requires a clear explanation. My goal is to have the canvas act as a background element on the page, while the main content of the page starts in its usual position. I attempted using separate DIVs with their own Z-index values, bu ...

How can I identify when a browser window is maximized using JavaScript or CSS?

I am currently working on a dashboard designed for static display on large monitors or TVs for clients. My main goal is to implement CSS styling, specifically a snap-scroll feature, but only when the display is in 'fullscreen' or 'maximized& ...

jQuery text slideshow not working properly when a <br> tag is present

I'm looking to develop a basic text slideshow that smoothly transitions between phrases and loops continuously. However, I've run into an issue where the slideshow malfunctions when I add a line break in the text. It only seems to work properly w ...

Having difficulty getting the sign operator to show up in a text field

Whenever the ADD div is clicked, "+" should be displayed on the textbox. The same goes for SUBTRACT, MULTIPLY, and DIVIDE. However, I am struggling to make the operators show on the textbox. Here is what I have managed to come up with so far. <!D ...

Using CSS to resize an element with both dimensions while maintaining its

Is it feasible to preserve a 1:1 aspect ratio on a div element using the CSS resize property? This particular illustration lacks an aspect ratio. Do you have any recommendations? ...

Ways to Create a Webpage with a Single Color Palette

Struggling to update the background color on my webpage and hitting a wall. Even with content, the black background only extends as far as the content does. I've experimented with extending the content, using the body selector, and universal selector ...

Incorporating a progress bar into the file upload feature

Looking to incorporate a minimalist progress bar using jQuery into this HTML. Any suggestions on the simplest approach? Just need a percentage value and a progress bar. <!DOCTYPE html> <html> <body> <form action="basic.php" method= ...

Positioning the video tag bar in HTML is a crucial element to

**Take a look at what I'm discussing here(http://jsfiddle.net/VpLyR/). I'm dealing with a simple code that includes a video tag (html) and a menu bar with a fixed position. The issue arises when I scroll down to the point where both the menu bar ...

What could be the reason for my Bootstrap collapse navigation bar not functioning properly?

<!DOCTYPE html> <html lang="en"> <head> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <!-- Optional theme --> ...