What is the method to align the center image while maintaining responsiveness in CSS?

Behold my HTML:

                    <div class="row">
                <div  class="row-fluid ">
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                        <a href="#" id="button1" "></a>
                    </div>
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                        <a href="#" id="button2" ></a>
                    </div>
                </div>
                <div  class="row-fluid ">

                    <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12 SetPadding textaligncenter">
                        <a href="#" id="centerbutton" ></a>
                    </div>
                </div>
                <div  class="row-fluid ">
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                         <a href="#" id="button3" ></a>
                    </div>
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                         <a href="#" id="button4" ></a>
                    </div>
                </div>
                </div>

Here's some CSS

#button1 {background: url('../img/button1.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                #button2 {background: url('../img/button2.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                **#centerbutton{background: url('../img/buttoncenter.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}**
                #button3 {background: url('../img/button3.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                #button4 {background: url('../img/button4.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}

This is what I expect it to look like

https://i.sstatic.net/CQ3Y8.png

I've attempted absolute positioning for the center button, but resizing the window causes issues.

Answer №1

The element in your HTML is labeled as id="centerbutton"

However, the CSS is currently aimed at #buttoncenter

... or it was until you made changes

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

Inserting JQuery Selector from a .js file into a .php file at the beginning

Incorporated in my project is a jquery plugin for a slider, which includes the code snippet below for handling 'next and prev' buttons. $(selector).prepend('\ <ul class="mk-nav-controls">\ <li>& ...

Adding the 'active' class using jQuery: a quick tutorial

I'm really stuck on why this isn't working. There doesn't seem to be any errors in my code. If anyone could offer some help in resolving this issue, I would greatly appreciate it. https://i.sstatic.net/M9jpd.png ...

How can you horizontally align a collection of elements using CSS?

I'm struggling to align a paragraph element with a group of button elements using jQuery and CSS. This is my issue: My goal is to have all these elements on the same horizontal line at the top of the screen to make the most of the pixel real-estate. ...

Display all images in a dynamic jQuery gallery popup

I am looking to create a dynamic model popup, so I have written the following JavaScript code. However, when I click on a single image, the model popup shows all images' content in a dynamically created div. I want the same image and its content to ap ...

Why can I only click on the text of my button?

Looking for a quick fix here! I've been trying to make the entire button clickable, but so far, only the text is hyperlinked. Any suggestions on how to enclose the whole button with the link? As you can see, I'm working on making it mobile-friend ...

When you click on links and buttons, a focus outline appears

I am currently troubleshooting an issue within an existing application that relies on the use of jQuery. The problem arises when I click on any link or button on the page, causing the element to display a focus outline (such as a blue glow in browsers like ...

How can I create a dropdown option within a select box in HTML using JavaScript or jQuery?

I am trying to enhance the functionality of a select box on my website. Here is the code snippet: <select name="cars" id="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> ...

Steps for repairing a button positioned at the top of a nested container within a form

My search form includes side filters to help users narrow down their search, with the results appearing on the right. This is just a basic example, as my actual setup involves more filters. However, there is one issue – users have to scroll down the pag ...

Once an element is removed from ng-repeat, it does not provide the capability to remove or conceal the element from

The following code is used to display records using ng-repeat: <div class="gallery"> <div ng-cloak ng-repeat="photo in photos| orderBy:'-id'" ng-mouseLeave = "delete_btn = !delete_btn" ng-m ...

Tips for opening a new browser tab

I'm having trouble getting my code to open in a new browser tab. Can someone help me figure out what's wrong? function getWaterMeterList() { // alert("ON"); var BillingPeriod = $('#BillingPeriod').val(); $.ajax({ ur ...

A guide on using key arrows in JavaScript to navigate and focus on elements

When working on my HTML project, I have a list of elements that I want to be able to select using the arrow keys. I've included my code here for reference: [http://jsfiddle.net/T8S7c/] What I'm trying to achieve is when the arrow keys are press ...

Error: Value of incoming scope in Angular Directive is not defined

When working in html, I passed an object into a directive like this: <lcd-code ldcCode="{{ detail.program.ldcCode }}"></lcd-code> The value of detail.program.ldcCode is "PSIH"... However, in the Directive, it is showing up as undefined: var ...

Sliding background in a multi-column accordion

I've hit a roadblock with this project. I'm working on setting up a FAQ section that needs to display its items in two columns on desktop, each with a drop shadow effect using Bootstrap 4. I've experimented with Flexbox and CSS columns with ...

Do elements containing {visibility:hidden} properties exist within the HTML DOM structure?

Do HTML elements that have the css property visibility:hidden still exist within the DOM tree? ...

Utilizing Cordova and AngularJS to efficiently retrieve JSON data through XMLHttpRequest in a factory

I've encountered an issue while attempting to retrieve a JSON from an API using XMLHttpRequest within a factory. Despite the debug logs suggesting that everything is functioning correctly, I keep getting an "undefined" response. Below is the code for ...

Generate interactive buttons within a grid layout by utilizing HTML anchor tags

Creating dynamic buttons in a grid within an accordion is my goal. The code I currently have is static, but I am looking to make it more flexible and dynamic. Ideally, the number of buttons needed in the grid will be determined at runtime. While the column ...

Certain issues arise when adjusting the padding within the background color of solely the inline text element

Appreciate your time. I'm working on adding background color to the TEXT exclusively, and have successfully done so by styling .post-title { text-transform:capitalize; margin-top:4px; margin-bottom:1px; font-size:22px; background-color:#FFF; dis ...

Ribbon design in LESS/CSS does not maintain its structure when resized in Google

My CSS/LESS ribbon is displaying perfectly in Firefox, but encountering issues in Chrome when resizing the window. At 100% zoom, everything looks good, but adjusting the zoom causes elements to become misaligned. To make it easier to troubleshoot, I' ...

Adding Light and Dark Themes to Vaadin Tooltip: A Step-by-Step Guide

Using the Vaadin tooltip component in my HTML has been quite helpful. Here's an example of how I've implemented it: <h1 id="heading-2"> salam <vaadin-tooltip theme="dark" for= ...

What is the best way to extract data from various HTML files using RVEST and save it into an Excel spreadsheet?

I am struggling to find a solution for my current problem as I am not fluent in R. My challenge is working with 800 html files and accessing all the h2 elements within each file. Currently, I have managed to do this with individual website URLs using the ...