EzDevInfo.com

alignment interview questions

Top alignment frequently asked interview questions

How to center an iframe horizontally?

Consider the following example: (live demo)

HTML:

<div>div</div>
<iframe></iframe>

CSS:

div, iframe {
    width: 100px;
    height: 50px;
    margin: 0 auto;
    background-color: #777;
}

Result:

enter image description here

Why the iframe is not centrally aligned like the div? How could I centrally align it?


Source: (StackOverflow)

Horizontally center a div in a div

How can I horizontally center a <div> within another <div> using CSS (if it's even possible) when the outer <div> has width: 100%?

For example:

<div id="outer" style="width: 100%">  
  <div id="inner">Foo foo</div>
</div>

Source: (StackOverflow)

Advertisements

Purpose of memory alignment

Admittedly I don't get it. Say you have a memory with a memory word of length of 1 byte. Why can't you access a 4 byte long variable in a single memory access on an unaligned address(i.e. not divisible by 4), as it's the case with aligned addresses?


Source: (StackOverflow)

Responsive image align center bootstrap 3

I do a catalog using Bootstrap 3. When displayed on tablets, the product images look ugly because of their small size (500x500) and a width of 767 pixels in the browser. I want to put the image in the center of the screen, but for some reason I can not. Who be will help solve the problem?

enter image description here

You can see a live example here.


Source: (StackOverflow)

How do I vertically center UITextField Text?

I am simply instantiating a UITextField and noticing that the text doesn't center vertically. Instead, it is flush with the top of my button, which I find kind of odd since I would expect the default to center it vertically. How can I center it vertically, or is there some default setting that I am missing?


Source: (StackOverflow)

What is the Auto-Alignment Shortcut Key in Eclipse?

What is the auto-alignment shortcut key in Eclipse?


Source: (StackOverflow)

UILabel Align Text to center

How do I align text in UILabel?


Source: (StackOverflow)

How to align 3 divs (left/center/right) inside another div?

I want to have 3 divs aligned inside a container div, something like this:

[[LEFT]       [CENTER]        [RIGHT]]

Container div is 100% wide (no set width), and center div should remain in center after resizing the container.

So I set:

#container{width:100%;}
#left{float:left;width:100px;}
#right{float:right;width:100px;}
#center{margin:0 auto;width:100px;}

But it becomes:

[[LEFT]       [CENTER]              ]
                              [RIGHT]

Any tips?


Source: (StackOverflow)

How to align a
to the middle (horizontally/width) of the page

I have a div tag with width set to 800px. When the browser width is greater than 800px, it shouldn't stretch the div but it should bring it to the middle of the page.


Source: (StackOverflow)

right align EditText android

I have an EditText in my application. I want to align the text in it to the right instead of the default left. I tried adding

android:layout_gravity="right"

but this doesn't seem to work. any other suggestions please?


Source: (StackOverflow)

Set cellpadding and cellspacing in CSS?

In an HTML table, the cellpadding and cellspacing can be set like this:

<table cellspacing="1" cellpadding="1">

How can the same be accomplished using CSS?


Source: (StackOverflow)

Label Alignment in iOS 6 - UITextAlignment deprecated

Seems like UITextAlignmentCenter is deprecated in iOS 6.

I still use it and works well, but it gives a warning.

How can I fix this?

label.textAlignment = UITextAlignmentCenter;

Thanks.


Source: (StackOverflow)

Align labels in form next to input

I have very basic and known scenario of form where I need to align labels next to inputs correctly. However I don't know how to do it.

My goal would be that labels are aligned next to inputs to the right side. Here is picture example of desired result.

enter image description here

I have made a fiddle for your convenience and to clarify what I have now - http://jsfiddle.net/WX58z/

Snippet:

<div class="block">
    <label>Simple label</label>
    <input type="text" />
</div>
<div class="block">
    <label>Label with more text</label>
    <input type="text" />
</div>
<div class="block">
    <label>Short</label>
    <input type="text" />
</div>


Source: (StackOverflow)

center aligning a fixed position div

I'm trying to get a div that has position:fixed center aligned on my page.

I've always been able to do it with absolutely positioned divs using this "hack"

left: 50%; width: 400px; margin-left:-200px

...where the value for margin-left is half the width of the div.

This doesn't seem to work for fixed position divs, instead it just places them with their left-most corner at 50% and ignores the margin-left declaration.

Any ideas of how to fix this so I can center align fixed positioned elements?

And I'll throw in a bonus M&M if you can tell me a better way to center align absolutely positioned elements than the way I've outlined above.


Source: (StackOverflow)

How to vertically center divs?

I'm trying to make a small username and password input box.

I would like to ask, how do you vertically align a div?

What I have is:

<div id="Login" class="BlackStrip floatright">
   <div id="Username" class="floatleft">Username<br>Password</div>
   <div id="Form" class="floatleft">
   <form action="" method="post">
      <input type="text" border="0"><br>
      <input type="password" border="0">
   </form>
   </div>
</div>

How can I make the div with id Username and Form to vertically align itself to the center? I've tried to put:

vertical-align: middle;

in CSS for the div with id Login, but it doesn't seem to work. Any help would be appreciated.


Source: (StackOverflow)