Using the display property with inline-block causes my text to move in a vertical direction

I'm looking to create a layout with 6 divs positioned relatively as clickable buttons - 3 on top and 3 on the bottom, each containing specific text. However, I've run into an issue where longer words cause some of the buttons to shift position. I suspect this problem is related to the "display: inline-block" property.

Here is the HTML:

<div class="Box_parent">
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div></a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div></a>
<a><div id="Box_button"> <div class="box_text"> REALLY REALLY REALLY LONG TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> REALLY REALLY REALLY LONG TEST </div> </div> </a>
<a><div id="Box_button"> <div class="box_text"> TEST </div> </div> </a>
</div>

And here is the CSS:

#Box_button{
height:300px;
width:300px;
background-color:#4286f4;
margin:15px 15px;
display: inline-block;
}

.box_text{
font-family:Arial;
color:white;
font-size:30px;
}

.Box_parent{
position:relative;
text-align:center;  
max-width:1300px;
margin:auto;
margin-top:130px;
vertical-align: bottom;
}

Answer №1

Ensure that the inline-block element has vertical-align property added to it.

#Box_button{
height:300px;
width:300px;
background-color:#4286f4;
margin:15px 15px;
display: inline-block;
vertical-align: middle;
}

By the way, it's essential for IDs to be unique on a webpage. Consider changing box_button to a class instead.

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

Ways to achieve a consistent font style in a Photoshop design

After recently starting to dabble in Photoshop, I managed to create a cool text effect a few days ago. Now, I'm looking to achieve the same effect and apply it to a different image. The text contains a date that I want to update, but I can't reme ...

Having troubles with PHP retrieving images from my server directory over here

My current code is designed to retrieve an image from my server and display it on my HTML page. However, the images are stored in an encrypted format using MD5 and do not have corresponding names in the table. To fetch the image, I am using the primary key ...

Unable to choose anything within a draggable modal window

Can someone please assist me? I am struggling to figure this out. I can't select text inside the modal or click on the input to type text into it. I suspect it may be due to z-index issues, but I'm having trouble locating them. var currentZ = n ...

The issue of IE 6 not properly displaying a pop-up div with dynamic data when set to a width of 70%

I am trying to create a pop-up div with dynamic data that is centered on the screen. I have set the height to 300px, width to 70%, and enabled vertical scrolling. When viewing in IE7/IE8, the div appears as intended, centered on the screen with the specif ...

What could be causing the lack of alignment in my div element?

For some reason, I just can't seem to center the ul#footer element on my page. It's frustrating because everything else is perfectly centered except for this one. http://jsfiddle.net/w67rt/ ...

Incorporating a jQuery word count and limit within PHP code: a step-by-step guide

I am encountering an issue with a textarea count code. It functions perfectly on its own but when I integrate it as shown below, it stops working without throwing any errors. I have been trying to resolve this for more than 3 days now. Any assistance would ...

How to assign a class to a dynamically created span in HTML using AJAX and PHP arrays

I'm puzzled as to why this keeps breaking. In my array, I have multiple words stored: $poolOne=array("sparkly","sporty","happy","confident","awesome","funny","awkward","mad","silly","dynamic", "handsome","merry","horrid","funky","loud","chirpy", ...

"Modifying the form-control-lg class in Bootstrap and AngularJS affects input size exclusively, leaving the label unaffected

Currently, I am focusing on enhancing an AngularJS custom text input component: <div class="form-group has-feedback" ng-class="[$ctrl.sizeClass, {'has-error': $ctrl.isNotValid(), 'has-success': $ctrl.isValid()}]" > ...

Is it possible to seamlessly incorporate a square image into a bootstrap background image slider without having to crop the image?

I've exhausted all the different solutions I've come across on other platforms to resolve this issue, but I'm still unable to find a fix. So here's what I'm struggling with: The problem I'm facing involves finding the correct ...

HTML5 enables the creation of an imperceptible scrollbar

I am looking to make my scrollbar invisible without it being visible however, I still want it to function when hovering over the box Also, I need it to work smoothly on both tablets and computers, which is why I have opted for using html5 I would great ...

Arranging divs in succession using CSS positioning

Struggling to design a landing page with a fixed background slideshow followed by a div explaining the website's purpose, I encountered an issue where the two divs overlap due to the current HTML and CSS code. Even after experimenting with different ...

What is the best way to insert a JavaScript variable into a filter while using ng-repeat?

I'm currently working on a situation where I have the following code: <div ng-repeat="i in MediaFeedItems | filter: { category: 'userSelect' }" class="mediafeed--item"> This specific code snippet is responsible for iterating through ...

Inline-block styling behaving incorrectly within span element

I am facing an issue with aligning a validation message inline with a textbox in my HTML code. Despite trying various options, the validation message appears just below the textbox instead of beside it. Below is the snippet of the code in question: HTML ...

Tips for sending all form elements via ajax without explicitly mentioning their names

I'm developing an application with a dynamic form generation feature. When a button is clicked, I need to send all the form elements to another page using Ajax. The challenge is that since the form is generated dynamically, I am unable to specify elem ...

How can I eliminate the white bar elements from my dropdown menu? Also, seeking guidance on replacing an empty <div> tag in a boolean query

Can anyone help me understand the strange white border around my dropdown menu and guide me on how to remove it? I am currently using DropdownButton from react bootstrap. I have attempted to adjust the CSS with no success. Here is the code I tried: .Navig ...

Why do I have to press the button twice for it to actually work?

I am new to programming and I want to create something that has 3 buttons to control the display of 3 hidden images respectively. When I click the first button, the image appears immediately, but I have to click it twice to show the second image. Can anyon ...

The issue of Django tooltip translations failing to work when there are white spaces present

While translating an html tooltip using i18n, I encountered a issue where the text does not display properly when placed between translation tags {% translate ... %} unless spaces are removed. Here is the code without the translate tag: <th scope=" ...

Encountering a problem in vue.js: "The instance is referencing 'step1_category' which is not defined as a property or method during render"

I encountered an error that says, "Property or method 'step1_category' is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializin ...

Is there a way to update the parent value when the child is activated?

I need to create a dropdown menu for users to select their email provider - either gmail, hotmail, or outlook. Once they make a selection, I want the button text to update accordingly. The catch is that I can only use bootstrap for this project and cannot ...

"Switching a div's visibility when a link is clicked

http://jsfiddle.net/FsCHJ/2/ Currently, when I add another link, it automatically uses the same functionality as the toggle button. What I want is for "Toggle Edit Mode" to toggle a hidden div on and off. I attempted to modify the code from $("a").click(f ...