What could possibly be the reason behind the initial box dropping?

Having trouble finding the right words to describe this? Take a look at it on codepen.

http://codepen.io/rick-li/pen/JKEbw

<div class="container">
<h1></h1>
<div class="box">
<div class="sharePanel">
  <div>content</div>
</div>
<div class="sharePanel">  
</div>
</div>
</div>


body 
{
    font: 15px / 1.8em "Microsoft YaHei";
    line - height: 40px;
}

.container {
    width: 960px;
    margin: 20px auto;
    border: solid 1px;
}

.container h1 {
    text - align: center; /*center the inline-block*/
}

.container.box {

    text - align: center;
}

.container.sharePanel {
    display: inline - block;
    height: 100px;
    width: 100px;
    border: solid 1px;
    border - radius: 5px;
    margin - right: 10px;

}


Answer №1

To align content at the top, you can use the CSS property vertical-align: top;. By default, the value for vertical-align is baseline.

.container .sharePanel {
    vertical-align: top;
}

Answer №2

To ensure your content is aligned to the top of the div, add the CSS property vertical-align:top as the default property for inline elements is vertical-align:baseline

CSS:

.container .sharePanel {
 vertical-align: top;
}

For a more detailed explanation of this issue, check out the following link:

Cross-browser-inline-block

Answer №3

Consider trying something similar to the following

Cascading Style Sheets (CSS)


p{

}
body{
background: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAUQAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAgICAgICAgICAgMCAgIDBAMCAgMEBAQEBAQEBAYEBQUFBQQGBgcHBwcHBgkJCgoJCQwMDAwMDAwMDAwMDAwMDAECAwMFBAUJBgYJDQoICg0PDg4ODg8PDAwMDAwPDwwMDAwMDA8MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDM/8AAEQgAIAAgAwERAAIRAQMRAf/EAGYAAAMBAQAAA********AAAABAgMJAQEBAQ***************************AQAAAAAAAAAAAAAAAAAAAA/9oAD        AMBAAIRAxEAPwDslWRjUuWRIQAq289cGWsPnMyZHnPLWworsR2qbu2QK2LyBl0kflO86b7+M8yrVyvS1ZDK5Rcsg3jUP7WySQTHvDBNTFhXDyjhCLc8lIis6fdO/wATPIGGUCoC9YbEdhchWk0qIysO523+s8iLraBmGUo5Q5ZSoP2gNDYfP18zyBVs4SpsmORQK2TSC/UNSbTJ+NZ5FMFWxPdAdkjm0ETVOnZqTIifWeQCkKlSdhZ7ArFcgdusH8p1131+s8gEsVoU

HyperText Markup Language (HTML)

<!-- Begin container layout  -->
<div class="container">

  <h1></h1>
  <div class="box">
    <div class="sharePanel">
      content
    </div>
    <div class="sharePanel">

    </div>


  </div>
  <p></p>
</div>

Ensure you use vertical-align: top; to align elements correctly. You can view a sample on Fiddle

Answer №4

Consider implementing a design like this

<div class="contentPanel"> display content here </div>
 <div class="contentPanel">&nbsp; </div>

SUGGESTION

.wrapper .contentPanel {
  border: 1px solid;
  border-radius: 5px;
  display: inline-block;
  height: 100px;
  margin-right: 10px;
  text-align: center;
  vertical-align: top;
  width: 100px;
}

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

Is there a way to eliminate the blue formatting on my phone?

I've encountered a styling issue on my website when viewing it on mobile, specifically with links on iPhone. I've already attempted the solutions mentioned in this discussion: How do I remove the blue styling of telephone numbers on iPhone/iOS? ...

Choose a HTML element <a> containing a hyperlink reference and a nested child element <li>

Does anyone know of a way in javascript/css to select the (n) <li> in my code, while also specifying that the <li> must have a parent with the current <a> tag containing a specific href link? <a href="www.link.com">CATEGORY NAME& ...

How can I create a CSS Layout Template Module with a fixed footer?

Currently exploring the capabilities of the JQuery library for CSS Layout Template module Wondering if it's possible to set the height of a placeholder using *, allowing it to either push content down or fill up remaining space based on the viewport ...

When the content in the div exceeds its boundaries, it causes it to overlap with

In my design, I have a top menu with a z-index of 999 to ensure nothing covers it. However, I am facing an issue where a scrolling div is appearing on top of the menu bar even though it shouldn't. Any idea why this is happening? Here is the CSS for t ...

Which HTML Editing Software is Best for Me?

As a college student, I have completed multiple web development and design courses. Throughout the past few years, I have utilized various tools such as PHPStorm, Visual Studio Code, Notepad++, SublimeText3, and Atom. Although I don't necessarily hav ...

:selected element malfunctioning

I've been struggling to make the following code work: html <div class = "col-md-4 video text-center wrapper-q1"> <p class = "no-padding"> <input class="question1" id = "vraag1" type="radio" name="q1" value="Moon"> < ...

Hey there, I'm looking to make sure that my div is consistently bigger than my content, even with text that cannot wrap. Can you help me figure out how to

Behold the current appearance of my window: https://i.sstatic.net/iIxDS.png Despite my efforts to maintain proper sizing, when I shrink the screen, the text (with white-space set to nowrap) ends up looking like this: https://i.sstatic.net/uXqox.png Is t ...

Move a 'square' to a different page and display it in a grid format after clicking a button

I am currently developing a project that allows students or schools to add projects and search for collaborators. On a specific page, users can input project details with a preview square next to the fields for visualization. Once the user uploads the ...

The CSS transition duration is not being applied properly on the initial transition effect

Looking to create a dynamic set of sliding divs that can be triggered with the press of a button. Each div will contain a thumbnail image and accompanying text. The goal is to enable the user to navigate through the content by clicking the left or right bu ...

Implementing a consistent CSS structure for various media sizes

Utilizing CSS grid and Sass, I implement varying grid layouts for different screen sizes (phone, tablet, desktop). However, on certain pages, I desire the same layouts at slightly larger or smaller screens than others. Is there a way to achieve this witho ...

The Hamburger Menu in the Bootstrap Navbar is failing to collapse

My website uses Bootstrap v5.3 and I've added a navbar, but the hamburger icon is not collapsing on mobile devices when clicked. Can someone please review my code to see if there are any issues? I can't figure out what's wrong. <!DOCTY ...

Foundation 4 - image hover effect to display alternate image

I am a newcomer to Foundation 4, but I have some coding experience. Currently, I am in the process of transitioning my photography blog (www.momentaryawe.com/blog) from Wordpress with a custom theme to a custom theme built on Foundation 4. Most aspects of ...

Tips for making a website display in landscape mode rather than portrait orientation

As a newcomer to web design, I am curious if it is feasible to create a website that automatically rotates to landscape view when accessed on a mobile device. The current project I am working on is fluid in design, so this feature would greatly enhance t ...

What is the best way to move the numerical range value into a span element?

How can I implement the "update" function to retrieve the current slider value and transfer it to a Meter element with the message "Value: [current value]". The indicator color should be #ffff00 if the current value is at least 85, otherwise, it should b ...

Creating a specific order for Arabic strings in HTML is simple and can be done by utilizing

I need to adjust the ordering of a datetime written in Arabic numbers. I must use an Arabic string and currently have the following C# code written in Arabic: std.InnerText = "17-02-2016"; The current output is in Arabic numerals, displayed as ٢٠١٦- ...

What is the best approach to create a JavaScript search filter function spanning two pages?

Page1.html has a form with a drop-down menu containing options Color and Shape. There is also a submit button. Assuming Page2.html displays various shapes like Blue Square, Red Square, Blue Circle, Red Circle, is it feasible to create a JavaScript file th ...

The hyperlink function is not operational in Gmail attachments

Using an anchor tag to navigate to a specific section within the same page works perfectly when the HTML file is on my local machine. However, when I attach the file in Gmail and open the attachment, it doesn't work. Why is this happening? How can I m ...

What is the best way to implement the Active list element feature in my menu bar?

The current list element is : <li class="nav__item"><a class="nav__link nav__link--active " href="#"... The standard list element is: <li class="nav__item"><a class="nav__link " href=&quo ...

How can I ensure that my boxes are aligned in a straight line?

I'm having trouble with applying the style="display: inline-block" to each div. Can someone please assist me? https://i.sstatic.net/Gi75l.png Below is my HTML code: <div class="hobby" style="display: inline-block"> <di ...

The issue with clip-path not functioning correctly in Safari persists

My list of clipped elements is causing an issue when using the CSS3 clip-path method to clip an image into an SVG path. The clipping works perfectly, but in Safari (V 12.1.4), the position of the clipped element changes with each box. The element ...