CSS Div With Arrow Centre - css

I'm wondering how to go about creating a div with an arrow attached to the bottom pointing downwards. I can achieve that effect like so: http://jsfiddle.net/hyH48/.
However, I'm not sure how to ensure that the arrow is in the centre of the div? In the fiddle, it is positioned using:
left: 20px;
But can I dynamically set this to appear in the centre? Obviously with people viewing the page on different screen resolutions I can't know in advance the integer to put here.
Please help?

If you know how wide the arrow will be, you can do this (fiddle):
left: 50%;
margin-left: -20px; /* -(width/2)px */
Otherwise, you can use transforms with left: 50%:
left: 50%;
transform: translateX(-50%);

What you what to do is add left:50%; and margin-left:20px;to #mybox:after. See http://jsfiddle.net/hyH48/1470/

Related

Vertical Align Bootstrap panel with CSS

I have had a look at a number of the articles on here which seem to provide a fix for most people, apparently except for me.
I am using the following CSS on my website:
/* login page background */
body.function-login {
display:inline-block;
float:none;
vertical-align:middle;
height:100%;
background:transparent url("http://sheqcomply.com/loginbackground.jpg") no-repeat center center fixed;
background-size:contain;
}
No matter what I try I just cannot get the login box to vertically align within the page. I can provide the layout css and page html if needed but havent included it within this post as they are large.
The current code results in this
Thanks in advance
This is what I use often when I have to align things vertically, I position the element at 50% from top and then translate it with -50%. It should work for you too, but it also depends on the other css instructions you have there.
.function-login {
position: relative;
top: 50%;
transform: translateY(-50%);
}
Vertical alignment, a perenial favourite.
One way to achieve this is to have another div around the component. In your example this would be the child of container with class col-md-6 col-md-offset-3. For this you need to add the height: 100vh style. For your actual component div you then add the following style
position: relative;
top: 50%;
transform: translateY(-50%);
There's probably little tweaks you need to do in order to get the "right" alignment for your context, but this should do it.

Responsive text over image vertically centered

I have my text positioned in an image with the margin-top: - px in 2 columns.
See it here: http://nlbure-govobanda.savviihq.com/bureau/
I want to know how to center it vertically on every screen? So it automatically scales to the middle of the image, no matter what device.
Hope someone can help me out.
using relative position property and also top:50%, you may do it like this:
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}

div to float left

I am weak in css and can you please help with this problem. You can see problem by clicking on Login/Register link in the below url.
Test box url
This is done in drupal. I am not able get the css to make the div with id "toboggan-login" to appear under the "Login/Register" link
Forgot to mention. I put the below css code. It works in small resolution systems. But its does not work in my 22'' monitor.
div#toboggan-login {
position: absolute;
top: 23px;
left: 74em;
}
This will fix your issue:
CSS:
div#toboggan-login {
position:absolute;
left: 50%;
margin-left: 310px;
width: 160px;
}
Than if you want to distance it a bit from the Login/Register top, just add:
top:10px; or how much px you want!
To explain the above lines:
The left:50%; pushes your element in the middle of the screen, so even at window resize your element will stay there, centered.
But to set it appropriately to some center-left position than we add position-left that will adjust the element position to a desired amount of px left from the center.

putting image always in center page

putting image always in center page(E.x image loading for ajax call), even when move scroll. how is it?
For most browsers, you can use position:fixed
img.centered {
position:fixed;
left: 50%;
top: 50%;
/*
if, for instance, the image is 64x64 pixels,
then "move" it half its width/height to the
top/left by using negative margins
*/
margin-left: -32px;
margin-top: -32px;
}
If the image was, for instance, 40x30 pixels, you'd set margin-left:-20px; margin-top:-15px instead.
Here's a jsfiddle example: http://jsfiddle.net/WnSnj/1/
Please note that position:fixed doesn't work exactly the same in all browsers (though it's ok in all the modern ones). See: http://www.quirksmode.org/css/position.html
<style>
.CenterScreen{
position:fixed;
/*element can move on the screen (only screen, not page)*/
left:50%;top:50%;
/*set the top left corner of the element on the center of the screen*/
transform:translate(-50%,-50%);}
/*reposition element center with screen center*/
z-index:10000;
/*actually, this number is the count of the elements of page plus 1 :)*/
/*if you need that holds the element top of the others. */
</style>
If you add this class your element, it will be always center of the screen.
For example:
Hello world
This might help you : http://skfox.com/2008/04/28/jquery-example-ajax-activity-indicator/
Put the image in a div tag with some class name (centeredImage) and use the following css
div.centeredImage {
margin: 0px auto;
position: fixed;
top: 100px;//whatever you want to set top;
}

Auto positioning div as one scrolls the page down/up

Please see this UI sketch image, I have this div in sidebar (black box) on a certain site and as I scroll down or scroll up, I don't want it to hide...I want it to move itself down as I scroll down and move itself up as I scroll back up so that it never hides out. Can you recommend me some jQuery that can get this done? or something else. Please help, thanks.
Don't use jQuery for this please; it's pure CSS.
#MyDiv
{
position: fixed;
top: 10px;
left: 10px;
}
Adjust the exact position to your liking by adjusting top and left. Maybe you want it centered vertically like in the image (if the sketch is accurate in that aspect), in which case you have to deal with all the fun tricks necessary for vertical centering; hopefully in your case something like this would work:
#MyDiv
{
position: fixed;
top: 50%; /* This places the _top_ of the div in the middle of the page. */
left: 10px;
height: 500px;
margin-top: -250px; /* This moves the div upward by half of its height,
thus aligning the middle of the div with the middle
of the page. */
}

Resources