Align your content perfectly on a full-screen slick slider

Attempting to center content over a full-screen slick slider from kenwheeler.github.io/slick/, I used a flexbox but the content remains at the edge of the viewport. It seems like an issue with the position tag in the slick CSS, but I can't figure out my mistake.

Since it's my first time working with flex, maybe I'm overlooking something?

Check out the live website here

Here is the HTML:

<div class="wrapper">
<div class="main">
  <img class="logo" src="img/logo.png">
  <h1><a href="#">XXXXXX</a></h1>
  <h2>XXXX is a collaboration between <a href="#">XXXX</a> & <a href="#">XXXX</a></h2>
</div>
<div class="background">
  <div class="slide" style="background: url('bg/hlg1.jpg') no-repeat center center"></div>
  <div class="slide" style="background: url('bg/hlg2.jpg') no-repeat center center"></div>
  <div class="slide" style="background: url('bg/hlg3.jpg') no-repeat center center"></div>
  <div class="slide" style="background: url('bg/hlg4.jpg') no-repeat center center"></div>
</div>

And here is the CSS code:

*{
  min-height: 0;
  min-width: 0;
  cursor: crosshair;
}

html{
  height: 100%;
  min-height: 100%;
}

body{
  font-family: sans-serif, "Helvetica", "Arial";
  font-weight: bold;
  font-size: 62.5%;
  color: #fff;
  text-align: center;
  height: 100%;
  margin: 0;
  padding: 0;
  width: 100%;
  background: #000;
  min-height: 100%;
  overflow: hidden;
}

.wrapper {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide {
  height: 100%;
  width: 100%;
  background-size: cover !important;
}

.background {
  height: 100%;
  width: 100%;
  z-index: 0;
}

.slick-list,
.slick-track {
  height: 100%;
}

.slick-prev {
  position: fixed;
  left: 2vw;
  height: 4vh;
  width: 3vw;
  z-index: 2;
}

.slick-next {
  position: fixed;
  right: 2vw;
  height: 4vh;
  width: 3vw;
  z-index: 2;
}

.slick-slider {
  margin-bottom: 0;
}

.arrow:hover {
  cursor: crosshair;
}

.main {
  flex: none;
  top: 3vh;
  z-index: 1;
  max-width: 50%;
  position: absolute;
}

.logo {
  width: 25vw;
  margin: auto;
}

Answer №1

Given that the main element remains in a static position, you may apply the following CSS properties:

.main {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    z-index: 1;
}

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

Tips for determining the size and identifier of a newly appended element in jQuery?

Struggling to create a select element with a width="347px" and id="select-box-1". I attempted to use .append("select"), but my search on .append() didn't yield the desired results. Unsuccessful Attempt: .append("< ...

Do not allow numbers in the Vietnamese character set in the HTML pattern

I am looking for a RegEx pattern to validate the name field without allowing any numbers. Currently, my pattern allows numbers which is not what I want. [a-zA-Z'-ŠšŽžÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝŸÞàáâãäåæçèé ...

Consistent manipulation of the DOM through the Drag/Touchmove event

Seeking to incorporate Mobile Components through native Javascript and AngularJS. During my work on developing a Pull To Refresh directive for AngularJS, I utilized the touchmove event on a UL list. The goal was to pull a concealed div over a list with cu ...

Infinite layers of options in the dropdown navigation bar

I am facing an issue with a dynamically generated unordered list that I want to turn into a dropdown menu. The challenge is that I do not know how many levels there will be, and I only want to display one level at a time. Here is what I have tried so far ...

What is the best way to make an HTML element's width automatically adjust based on the margin size?

I'm currently working on creating a rectangular button using HTML and CSS. The challenge I'm facing is ensuring that the width of the button remains consistent regardless of the amount of text it contains. Whether it's just a few words or mu ...

Convert your HTML document into a Microsoft Word file and see the total number of pages in

I have been experimenting with creating a Word document using HTML code. Thanks to various examples, I have made some progress. However, I am facing an issue where I cannot get the total number of pages to display as text on the first page of the document. ...

Div that scrolls only when children can be displayed without overflowing

I am seeking a solution to ensure that the children inside my scrollable div are only visible in their entirety. HTML <div id="container"> <div class="child"></div> <div class="child"></div> <div class= ...

Text spilling out of a floated division

I'm currently working on a fluid layout design, but I've encountered an issue with the left menu text overflowing. I can't seem to get overflow:hidden to work properly. You'll notice that in the blue area, I have highlighted the text t ...

I am attempting to trigger a mouseup event following a mousedown action

elements[0].onmousedown = function(){ console.log('screen clicked.'); triggerMouseUp(); }; I just need to incorporate a function in my code that simulates mouseup event, even when the user is still holding down the click button. e ...

Strange outcomes observed with CSS Selector nth-child

When utilizing the CSS nth-child selector, I am encountering some peculiar issues. The HTML structure is as follows: <div class="block feature-callout-c" id="overview"> <div class="row"> <div class="span twelve"> ...

JQuery restricts input to only allow numbers with a set number of digits, ensuring uniqueness

Can someone assist me in creating a jQuery script that only allows unique numbers with exactly 4 digits in a numeric field? Here is the HTML code: <input type="text" id="registration_number" class="input-sm" name="registration_number" maxlength="6" re ...

I am experiencing an issue with using double quotation marks in VS Code

Whenever I press the double quote symbol like this "", the cursor automatically moves to the end. While this may be natural, I would prefer the cursor to move inside the double quotes automatically when pressing them. Additionally, it's a bi ...

Explore the limitless possibilities of using jQuery Superscrollorama with fixed backgrounds

I am looking to achieve a scrolling effect with multiple elements, specifically three pictures in this case. While it is easy to implement scrolling, my goal is to keep the background fixed during the scroll event and have it move once the scrolling is co ...

Showcase -solely one property object- from numerous property objects enclosed within an array

Hello, I am seeking assistance as I have recently begun learning about angularJS. I am working with objects that have keys such as: scope.eventList=[]; for(){ var event = { id : hash, ...

When you click on a sublevel in the vertical CSS and JavaScript onclick menu, it disappears automatically

I'm a beginner when it comes to Javascript, and I'm still getting the hang of CSS/HTML. Currently, I am working on creating a vertical menu using CSS and javascript. My goal is to have the sublevels appear on the right side of the menu when someo ...

The app constantly requests permission for geolocation services

While experimenting with the geolocation API, I encountered an issue where my page kept repeatedly asking for permission upon refresh. To work around this problem, I attempted to save my coordinate data to local storage but encountered difficulties in ma ...

Tips for toggling the visibility of a <div> element using PHP code inside

I'm having trouble with a dropdown list that is supposed to show/hide some divs containing PHP files. However, when I try to toggle the visibility of the divs using the dropdown list, it doesn't seem to work as expected. Can anyone help me figure ...

Elements powered by jQuery failing to load upon dynamic webpage(s) loading via ajax

Dynamic loading of jQuery elements, such as Ibuttons, seems to be causing issues when implemented with an ajax dynamic content loader. The entirety of my website is rendered through Ajax just like this: <html> <header> {jQuery} </header> ...

Alter the style of a div by clicking on a button

Can the background image of a div be changed by selecting a button outside of the div? For example: HTML <div id="change"></div> <div id="buttons"> <button class="button1">this</button> <button class="button2"> ...

Connections between Wordpress websites and CSS styling

My inquiry consists of three parts: I am currently in the process of constructing a portfolio website using Wordpress, and I have encountered some peculiar links. For instance, on my about page, the link appears as localhost/AFolder/anotherfolder/ind ...