How to Align a Button in the Middle with Bootstrap?

Hey there! I'm working on creating a video list. I've utilized the bootstrap grid system to put it together. Here's the code I have so far: I'm trying to center the play button both vertically and horizontally within the thumbnail. Any suggestions on how I can update the code?

.test {
    width: 100%;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    position: relative;
}
.quick-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}
.kkk {
    position: absolute;
    z-index: 1;
    top: 25%;
    left: 45%;
    font-size: 60px;
    opacity: 0.6;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
<script src="//cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
    <div class="row">
        <div class="col-lg-6 col-sm-12 ">
            <div class="test">
                <a href="//google.com">
                    <img class="quick-img" src="http://imgs.aixifan.com/content/2017_10_02/1509609180.png" />
                    <button class="kkk glyphicon glyphicon-play"></button>
                </a>

                <h2 style=" word-break: break-all;
      word-wrap: break-word;">title test</h2>
            </div>
        </div>
        <div class="col-lg-6 col-sm-12 ">
            <div class="test">
                <a href="//google.com">
                    <img class="quick-img" src="http://imgs.aixifan.com/content/2017_10_02/1509609180.png" />
                    <button class="kkk glyphicon glyphicon-play"></button>
                </a>

                <h2 style=" word-break: break-all;
      word-wrap: break-word;">title test</h2>
            </div>
        </div>
        <div class="col-lg-6 col-sm-12 ">
            <div class="test">
                <a href="//google.com">
                    <img class="quick-img" src="http://imgs.aixifan.com/content/2017_10_02/1509609180.png" />
                    <button class="kkk glyphicon glyphicon-play"></button>
                </a>

                <h2 style=" word-break: break-all;
      word-wrap: break-word;">title test</h2>
            </div>
        </div>
    </div>
</div>

Hello Friend! I'm in the process of creating a video list. I've utilized the bootstrap grid system to put it together. Here's my code I'm looking to center the play button both vertically and horizontally within the thumbnail. Any advice on how to adjust the code?

Answer №1

To enhance the styling of your webpage, consider incorporating the following CSS code snippet:

.example a { display: block; position: relative; }

button.special { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

Answer №2

Consider enhancing your css with the following:

.kkk  
{
    padding-top:50px;
}

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

Increase the size of the embedded iframe in your Cordova application by using the pinch-to-zoom

I have been struggling with this issue for the past few days and am having trouble finding a solution.. I am trying to figure out how to embed an iframe in a cordova app (running on an iOS device) to display an external webpage while allowing users to pin ...

Multiple 'keydown' events are accumulating with Ajax activated

When the search field is focused, I am loading JSON into the browser and then iterating over the JSON objects to find real-time results 'on keydown'. The issue I'm encountering is detailed in the console after the initial block of code Aja ...

CSS smoothly scrolls upward within a set height restriction

Is there a way to use CSS to ensure that the scroll bar of a fixed-height message box is always at the bottom, displaying the latest entry? Currently, as more messages populate the chat box main section, everything inside remains static. The only way to v ...

Maximizing the potential of image srcset in HTML5

After configuring the img srcset as shown below: <img srcset="http://via.placeholder.com/320x150 320w, http://via.placeholder.com/480x150 480w, http://via.placeholder.com/800x150 800w" src="http://via.placeholder.com/8 ...

What steps should I take to update the state of this navbar?

Trying to understand why the prop I want to pass won't work with the toggle function: function custToggle({e}){ e.custOrFalse= !e.custOrFalse; var custButton='cust page' if ( e.custOrFalse==true ) { custButton='cust lo ...

Modifying the font style and color of text within the table header - Material Table version 0.19.4

Recently, I began using React and Material UI but have encountered an issue with modifying the color and font of text in the table header. Despite attempting to override it, the default style remains unchanged. It has been mentioned that utilizing "heade ...

Switch between Coordinated Universal Time and a designated time zone using the New Internationalization API

I am experimenting with the new Internationalization API using Chrome Version 31.0.1623.0 canary. My goal is to: Convert Date Time between UTC and a specific time zone (America/New_York as an example). Determine if the conversion takes into account Dayl ...

Tips for effectively combining the map and find functions in Typescript

I am attempting to generate an array of strings with a length greater than zero. let sampleArray2:string[] = ["hello","world","angular","typescript"]; let subArray:string[] = sampleArray2 .map(() => sampleArray2 .find(val => val.length & ...

The lookAt method in THREE.js is not functioning properly when called after the rendering process

The code snippet below seems to be causing some issues. It requires jquery and three.js to function properly. The problematic lines are as follows: // change the view so looking at the top of the airplane views[1].camera.position.set( 0,5,0 ); views[1].ca ...

Navigating through Node and Express on Azure App Service

I'm facing an issue that I am not sure if it is related to Node or Azure App Service, so here's the situation: In my Node/Express app, I have defined two routes: router.get("/users", checkAuthHeader, userController.getUsers); router.po ...

What are the top techniques for designing with Angular 2 Material Design?

As a newcomer to angular 2 material design, I have noticed the primary, accent, and warn classes that apply specific colors to elements. Are these the only styling options available in Angular Material 2? Are there other classes that can be utilized for cu ...

Looking for a dropdownlist with checkboxes in asp.net mvc but without the use of Entity Framework

I am in need of a dropdown list with checkboxes in asp.net mvc. The issue is that my view already has a layout page with existing script files, which seem to be causing a disturbance in the original layout. I have tried various solutions such as rearrangi ...

Utilize Launchdarkly in React by incorporating it through a custom function instead of enclosing it within

Currently, I am adhering to the guidelines outlined by launchdarkly. Following the documentation, I utilized the following code snippet: import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk'; (async () => { const LDProvider = a ...

The Python socket fails to receive a valid response after sending an HTTP 1.1 CONNECT request

I am attempting to create a simple program that establishes an https tunnel with www.google.com on port 443. Initially, I used the code below: import socket def main(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("www.google. ...

ng-select search functionality failing to display any matches

Currently, I am encountering an issue with the ng-select functionality in my Angular CLI version 11.2.8 project. Despite using ng-select version 7.3 and ensuring compatibility with the Angular CLI version, the search functionality within the select eleme ...

Step-by-step guide on incorporating a new JSON object into an array to display its elements as components on a webpage

Could I adjust the state of an array by incorporating values from a data.js file as a starting point? The process involves executing the setAllThingsArray function to add a new element, determined by the setThingsArray function based on the previous state ...

The session variable fails to update across several requests

I am looking to track the number of requests sent by a browser and store it in the session. Below is the code snippet I have written: import express from 'express'; import expressSession from 'express-session'; import path from "pa ...

What is the best way to create a clickable background for a modal window?

I am looking to add a chatbox feature to my website and have been utilizing Bootstrap Modal for this purpose. My goal is to keep the modal open even when the user clicks outside of it, while still allowing them to interact with the background of the websi ...

The presence of a backslash is preventing the state from transitioning to '/{username:[a-zA-Z0-9]{3,20}}' within the AngularJs UI-router

In my abstract root state named 'site', the empty URL ('') contains two child states: 'profile' and 'home'. The URL for home is '/', while the URL for profile is '/{username:[a-zA-Z0-9]{3,20}}'. I ...

Having trouble locating and interacting with the textarea element in Salesforce using Selenium Webdriver

Encountering an issue with the Selenium Webdriver where it throws an error stating that the element is not visible and cannot be interacted with when attempting to access a textarea. 1. The textarea is located within a pop-up window, which can be accessed ...