Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8857189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:31:54+00:00 2026-06-14T14:31:54+00:00

Please, observe this simple jsFiddle: http://jsfiddle.net/mark69_fnd/vtLrt/10/ HTML: <div class=char> <div> <div class=char>A1</div> <div class=char

  • 0

Please, observe this simple jsFiddle: http://jsfiddle.net/mark69_fnd/vtLrt/10/

HTML:

<div class="char">
  <div>
    <div class="char">A1</div>
    <div class="char anchorToMiddle">D1</div>
    <div class="char anchorToRight">G1</div>
  </div>
  <div>
    <div class="char">A2</div>
    <div class="char anchorToMiddle">D2</div>
    <div class="char anchorToRight">G2</div>
  </div>
  <div>
    <div class="char">A3</div>
    <div class="char">B3</div>
    <div class="char">C3</div>
    <div class="char">D3</div>
    <div class="char">E3</div>
    <div class="char">F3</div>
    <div class="char">G3</div>
  </div>
</div>​

CSS:

.char{
    display: inline-block;
}


.anchorToRight {
    float: right;
}​

Output:

enter image description here

How can I change the HTML and/or CSS, so that the elements marked as anchorToMiddle (D1 and D2) be aligned in the middle, right above D3?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:31:55+00:00Added an answer on June 14, 2026 at 2:31 pm

    I tried to find a solution with some javascript (since the question was tagged with javascript).

    If you set text-align to “center” in “anchorToMiddle” the text will be centered but only if you specify the element’s width. To do this, B3..F3 are wrapped inside another div (with id “charspan”):

    <div id="charspan" class="char">
        <div class="char">B3</div>
        <!-- etc. -->
    </div>
    

    then this new div’s width is calculated and applied to the class “anchorToMiddle”.

    var elems, i, width, span;
    elems = document.getElementsByClassName("anchorToMiddle");
    span = document.getElementById("charspan");
    width = parseInt(window.getComputedStyle(span).width);
    for (i = 0; i < elems.length; i++) {
            elems[i].style.width = width + 'px';
    }
    

    Updated Fiddle: http://jsfiddle.net/Espesen/vtLrt/14/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please observe this fiddle: http://jsfiddle.net/8nrPm/3/ I have set the width of the Animation button
Please observe this stylesheet: http://jsfiddle.net/VjhJ4/12/ If you hover your mouse over the anchored menu,
Please see demo here: http://jsfiddle.net/mA6qm/1/ (expand console) Why aren't events being sent or received
Please, observe the following simple program (based on the example from the protobuf-net project
Why does this happen? Please observe the following code: static class StringExtension { public
I have this code. <html> <head> <script src=//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js> </script> <script> Event.observe('clickme', 'click', function(event) {
This post may seem long.. But it's very simple. So please please help. Thanks.
I'm pretty confused! with this: ... <div id=main> <div id=content> <div class=col1> ...COLUMN1 CONTENT
In my WPF UserControl I have this resource, please observe the comments in the
Please, observe: PS Z:\dev> hg version Mercurial Distributed SCM (version 1.9.2) (see http://mercurial.selenic.com for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.