Inconsistency in CSS alignment is noticeable

I'm currently working on a comment page, but I’m facing an issue where the alignment of the speech bubble is off.

For example:

I believe this can be resolved with CSS, but I’m not entirely sure. Here’s a link to my demo: http://jsfiddle.net/bSaJc/

Thanks in advance!

Here is the CSS code I am using:

.bubble-panel {
    display: inline-block;
    //border: 1px dotted #CCCCCC;
    height: 250px;
    position: relative;
    margin: 20px;
}


.bubble 
{
position: relative;
width: 535px;
height: 130px;
padding: 4px;
background: #FFFFFF;
-webkit-border-radius: 31px;
-moz-border-radius: 31px;
border-radius: 31px;
border: #46A5E4 solid 9px;
display:inline-block;
margin-bottom: 0px;
margin-right: 50px;

}

.bubble p
{
    margin: 10px;
}

.bubble:after 
{
content: '';
position: absolute;
border-style: solid;
border-width: 31px 14px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
margin-left: -14px;
bottom: -31px;
left: 20%;
}

.bubble:before 
{
content: '';
position: absolute;
border-style: solid;
border-width: 39px 22px 0;
border-color: #46A5E4 transparent;
display: block;
width: 0;
z-index: 0;
margin-left: -22px;
bottom: -48px;
left: 20%;
}
.caption {
    //border: 1px solid red;
    width: 20em;
    font-size: 14px;
    line-height: 1.5;
    position: absolute;
    bottom: 15px;
    right: 50px;
}
.caption h1, .caption h2, .caption h3 {
    font-size: 1.00em;
    text-align: left;
    margin: 0;

}

Answer №1

Take a look at this DEMO

I included the CSS rule vertical-align: middle;

.bubble {
   position: relative;
   width: 535px;
   height: 130px;
   padding: 4px;
   background: #FFFFFF;
   -webkit-border-radius: 31px;
   -moz-border-radius: 31px;
   border-radius: 31px;
   border: #46A5E4 solid 9px;
   display:inline-block;
   margin-bottom: 0px;
   margin-right: 50px;
   vertical-align: middle; /* MAKE SURE TO ADD THIS LINE */

}

Answer №3

Include the CSS property float:left in the selector .bubble-panel

.bubble-panel {
display: inline-block;
float: left;
height: 250px;
position: relative;
margin: 20px;
}

Check out the live demonstration here

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

"Authentic" foundation for typography

Line spacing in web design is different from line spacing in print design, such as in programs like InDesign. Here are the results: Web example: http://jsfiddle.net/Y9M28/4/ (works better in webkit) Print example: http://jsfiddle.net/Y9M28/3/ I have t ...

Aligning images in a table grid of 300px by 300px dimensions

I've included my code below and I am searching for the most effective method to use CSS to center an image both horizontally and vertically within a 300 by 300 pixel square. If the image is larger, it should be resized to fit within the square, while ...

Cause a JavaScript error to occur if geolocation services are disabled

I have an AngularJS project where I am utilizing the following code snippet to fetch a device's GPS coordinates: // when user clicks on geo button $scope.getGeoLocation = function() { var geocoder = new google.maps.Geocoder(); window.navigato ...

Page showing without banner

As I scroll down through my website, I want a specific banner to appear when I reach the contact page. The banner will show a goodbye message and give users the option to close it or keep it open. For example: (function() { requestAnimationFrame(fu ...

Alter the color of Material UI Raised Button when it is hovered over

I am trying to change the background color of a raised button on hover in Material UI. I attempted the following, but it did not work. Is there a way to modify the background color in Material UI for a raised button? Example.JS <RaisedButton ...

Is there a way for me to determine if an image is at the top of the screen?

As I scroll, I am looking for a way to hide my menu and trigger other actions when an image reaches the top of the screen. These images span the full width of the page, so they pass through every point on the x-axis. I've attempted using elementFromPo ...

Understanding the functionality of sessions in CodeIgniter when using AJAX

I am experiencing an issue with the Session in my code. It only works when the page is refreshed. I have a controller called ravi and the view named myview. Here is the code snippet: <?php class Ravi extends CI_Controller { public funct ...

deleting the selected list item with JavaScript

Currently, I am tackling a todo list project but facing a challenge in finding a vanilla Javascript solution to remove a list item once it has been clicked. Adding user input as list items was relatively simple, but I have come to realize that this specif ...

Is there a way to check the existence of an email in the database without having to refresh the PHP page?

Currently, I am using the following method to validate my inputs: <form method="post"> <label>Email</label> <input type="email" name="user_email"> <input type="submit" name="reg"> </form> if(isset($_POST['reg' ...

Design a styled rectangular tab using CSS

Does anyone know of any cool CSS techniques for achieving the tabbed rectangle appearance depicted in the image below? While it's clear that accomplishing this with just one div is not possible, is there a more efficient method than layering one div ...

Utilizing flexbox for dynamic width adjustment with flex-grow functionality

Currently, I am in the process of configuring a menu bar using this particular template I have been attempting to achieve this layout utilizing FlexBox, but it appears that there is an issue. Here is the HTML code: <nav> <ul> < ...

Utilize the return function in a separate PHP file

I wanted to create a basic login form as a way to dive into learning php. After setting up the form, I wrote a function that sends a query to a MySQL database to fetch the username and password (stored in md5 encryption) for comparison with user input. T ...

Shopify Inventory Dropdown Tailored to Stock Levels

I'm having an issue with my Shopify store. How can I make sure that the quantity dropdown matches the actual items in stock? For instance, if there are only 3 items available, the maximum value in the quantity dropdown should be set to 3. And if there ...

Adjust the background color of a div dynamically depending on a specified percentage, similar to a progress bar

I have a div containing some text along with a percentage value (e.g. 78%). I would like to represent this percentage as the background color of the entire div, not just a portion of it. <div class="my-div"> <div class="percentage-colored" ...

Having difficulty with the presentation of two images in one cell of an HTML table

Currently, I am working with an html table where I want to display two images in one cell. However, the issue I am facing is that both images are appearing together due to the styling applied so far. Is there a way for me to add a space in between the two ...

Tips for validating form data in JavaScript before invoking a PHP file

When working with a form that has an action attribute to call another PHP page, I want to ensure that one text field is not empty by validating it with JavaScript before submission. How can I accomplish this using the <input type"submit"> tag? ...

The alignment of the text is incorrect and needs to be fixed

In my code, I have an if statement that determines how the page should be rendered. <script language="JavaScript"> if (NS4) { document.write('<LAYER NAME="floatlayer" LEFT="22" TOP="60">'); } if ((IE4) || (NS6)) { document.w ...

Resizing SVG to specify width in pixels and automatically adjust height

I'm having trouble understanding how SVG works. Can someone explain where my mistake is? Here's an example of my inline SVG code: <div style="width:1000px; height:auto; background-color:blue;"> <svg class="_image"><use xlink ...

Is it feasible to obtain multiple tag-name indexes using JavaScript?

Exploring the table search function provided by W3Schools has brought up an interesting question in my mind. Is it feasible to simultaneously retrieve multiple indexes using getElementsByTagName and conduct a search across the entire table instead of just ...

Comparison between an empty div and a div containing text with the inline-block property applied

Curious about why this phenomenon is occurring. CSS div { display: inline-block; margin-right: 2px; width: 20px; background-color: red; } Empty div <div style="height:20px;"></div> <div style="height:40px;"></div> &l ...