Discover the secret to aligning HTML radio buttons vertically using only CSS in this snippet

I stumbled upon this amazing CSS-only slideshow with thumbnails for my project here. I've been experimenting with the code to try and align the thumbnails vertically on the right instead of horizontally at the bottom, but haven't had much luck...

The main image needs to be 640px by 640px:

    /*Customizing the CSS*/
* {margin: 0; padding: 0;}
body {background: #ccc;}

.slider{
    width: 640px; /*Same as the width of the large image*/
    position: relative;
    /*Using padding rather than height*/
    padding-top: 640px; /*This brings down the labels*/

    margin: 100px auto;

    /*Adding a shadow effect*/
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.75);
}


/*Adding transitions for smoother effects*/
.slider>img{
    position: absolute;
    left: 0; top: 0;
    transition: all 0.5s;
}

.slider input[name='slide_switch'] {
    display: none;
}

.slider label {
    /*Adjusting spacing for the thumbnails*/
    margin: 18px 0 0 18px;
    border: 3px solid #999;

    float: left;
    cursor: pointer;
    transition: all 0.5s;

    /*Setting default style with low opacity*/
    opacity: 0.6;
}

.slider label img{
    display: block;
}

/*Implementing click effects*/
.slider input[name='slide_switch']:checked+label {
    border-color: #666;
    opacity: 1;
}
/*Clicking on any thumbnail should change its opacity(style)*/
/*Working on the main images now*/
.slider input[name='slide_switch'] ~ img {
    opacity: 0;
    transform: scale(1.1);
}
/*Hiding all main images at 110% size
On click, displaying images at normal size for the complete effect
*/
.slider input[name='slide_switch']:checked+label+img {
    opacity: 1;
    transform: scale(1);
}

Answer №1

In order to achieve the desired layout in Chrome, I made some adjustments to a few elements. By simply tweaking the following CSS code, you can position the radio slider on the left and the image on the right with the correct size using transform: scale.

.slider {
      width: 640px;
      position: relative;
      /* padding-top: 320px; Remove the padding top */
      margin: 100px auto;
      box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.75);
    }

.slider input[name='slide_switch'] ~ img {
  opacity: 0;
  transform: scale(0.5);
  margin-left: 120px; /* Push the image to the right side.*/
}

Answer №2

In order to achieve vertical alignment, consider removing the .slider label float:left; property. Adjusting the border and position CSS may be necessary, but it should not be a complex task. I trust this information has been beneficial.

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 causes a button to move to a new line following a div element?

Why does a button move to a new line after a <div> element even though it's an inline element? If I try putting the button inside the <div>, it gets removed due to JQuery constantly updating the <div>. Is there any way to prevent the ...

Different methods for incorporating script-specific data into markup

How can we include extra meta data in HTML code to support client-side javascript functionality? Let's consider some straightforward examples: A list of contacts that, when clicked, displays their location on a map. For instance, how can we link la ...

Issue with Bootstrap 4 progress bar malfunctioning in popover due to CSS property restrictions within the popover container

The following code functions correctly in the body area: <div class="progress" style="height: 25px;"> <div class="progress-bar" style="width: 30%;" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"> </div> & ...

An error occurred: TypeError - Unable to access the 'value' property of a null object during a value change

Example ImageCreating a dynamic form where rows and select box options are added dynamically using 'x' and 'i' increment values in two JavaScript functions. The code works fine when the option selected is 0.5, but throws an error Uncaug ...

Troubleshooting issues with Javascript's innerHTML functionality

I've been searching extensively for a solution, but I can't seem to find exactly what I need. I know it should be possible to use a menu link (a div) as a trigger to change the HTML content in another div within the document, but I just can' ...

Adding a directive to dynamically loaded HTML in Angular 5

Once the HTML has been loaded, I am able to choose any HTML element by utilizing ElementRef.nativeElement.querySelector(). Can you provide guidance on how to implement a directive on the selected element? ...

How to create a stylish border line to separate rows using CSS

Having some trouble with HTML code... <table class="table table-condensed order-statistics"> <tr class="order-statistics-row"> <div class="row"> <div class="col-lg-4"> Order ID: </div> <div ...

Block public access to the root directory of my domain to enhance security

I have a website at www.domain.com. While inspecting the element and trying to access www.domain.com/css/, I noticed that it displayed all the files in the directory. The structure is as follows: /css/ /images/ /include/ /js/ index.html contact.html si ...

Can a CSS3 filter be utilized to transform gradient colors into solid colors?

I have an interesting scenario where I am using a -webkit-mask with a radial-gradient to create small dots on a background image. These dots are transparent, allowing the background image to show through. However, each dot has a gradient color within it. ...

The seamless integration of React.js with HTML

My friend and I are beginners in the world of programming, with a solid grasp of html, CSS, and JavaScript. We're currently collaborating on a small project where we aim to create a chat system. While researching resources for our project, we came acr ...

Interactive div containing elements that cannot be clicked

http://codepen.io/anon/pen/zxoYBN To demonstrate my issue, I created a small example where there is a link button within a div that toggles another div when clicked. However, I want the link button to not trigger the toggle event and be excluded from the ...

Does Xamarin.Forms have a feature similar to html datalist that enables the selection of predefined values while also allowing for the input of free text?

We are currently developing a Xamarin forms application. One of the necessary features is a selection field where users can either choose from predefined options or enter their own text value, similar to using a text field. In HTML, this could be easily ...

Tips for placing a background image within a button

Here is the CSS code I am currently using: .physButton:before { content: " "; display: inline-block; background: url("../theImages/ste.png") no-repeat; height: 38px; line-height: 38px; vertical-align: middle; width: 52px; / ...

Can JavaScript trigger an alert based on a CSS value?

Hello, I am facing an issue. I have created a blue box using HTML/CSS and now I want to use JavaScript to display an alert with the name of the color when the box is clicked. Below is my code: var clr = document.getElementById("box").style.background ...

Tips for transforming an SQL Server query into JSON format

I need to construct a table in a view utilizing the output of this particular SQL Query SELECT f.empresaid, e.fantasia AS Company, f.filialid, f.fantasia AS Branch, u.consultorid ...

Transitioning the image from one point to another

I am currently working on a unique single-page website and I have been experimenting with creating dynamic background animations that change as the user scrolls. Imagine my website is divided into four different sections, each with its own distinct backgro ...

Is there a bug causing this div to load inconsistently in Chrome?

Currently, I am using Chrome Version 33.0.1750.154 m on Windows 7 Professional 64 bit operating system A few years ago, I developed a WordPress plugin that displays a cached and stylized Google Calendar. The plugin works fine but could use some improvemen ...

What steps can I take to avoid horizontal scrolling on mobile due to a table overflowing?

My website displays a table within a bootstrap container, row, and column. While everything looks good on larger screens, the content within the table is causing a horizontal scroll on smaller screens, making the footer look distorted. This results in a me ...

Retrieve the Data from Input Fields with Matching Classes and Transmit to a Script Using AJAX Request

I am working on a form that includes multiple input fields: <input type="text" class="date" name="date[]" onkeyup="showHint()" /> <input type="text" class="date" name="date[]" onkeyup="showHint()" /> <input type="text" class="date" name="da ...

Having a problem with the hover effect on the navbar component

Whenever I hover over the individual links, I notice that the color change doesn't extend all the way up. I have a feeling there is a more efficient way to achieve this than my current approach. Any assistance would be greatly appreciated! HTML: < ...