center

Force align a content in center

一曲冷凌霜 提交于 2019-12-07 02:48:30
问题 I have some content which will contain some divisions, labels, forms in it. I want to force them in the center of page. How can I do this? Note: I tried using <div align="center"> , <center> but nothing works? 回答1: If your content doesn't have a fixed width do this: <div class="content"> <div class="inner">some content</div> </div> .content { text-align: center; } .inner { display:inline-block; } If it does, you could do this: .content { width: xpx; margin: 0 auto; } 回答2: You must use margin

center a div (absolute position and width)

核能气质少年 提交于 2019-12-07 02:14:25
i use below css to center my div with absolute position: #mydiv { position:absolute; top: 50%; left: 50%; width: 121px; height: 121px; margin-top: -60.5px; /*set to a negative number 1/2 of your height*/ margin-left: -60.5px; /*set to a negative number 1/2 of your width*/ } It works like magic. But as you can notice, it has fixed width and height. Now i have to use this same css but for my div which has no fixed width and height, as it uses responsive layouts. I just want to know is there any simplest way to set my div width dynamically in css by javascript or so? i.e., it count my div width

How to add annotation on center of map view in iPhone?

风流意气都作罢 提交于 2019-12-07 01:37:01
问题 I have MAP view in my app and i want to add Annotation pin (Red pin) on center of map view. Now when user scroll map view pin should adjust with center according to that. How to do that? Thank 回答1: If you want to use an actual annotation instead of just a regular view positioned above the center of the map view, you can: use an annotation class with a settable coordinate property (pre-defined MKPointAnnotation class eg). This avoids having to remove and add the annotation when the center

True Center Vertical and Horizontal CSS Div [duplicate]

南楼画角 提交于 2019-12-06 17:56:55
问题 This question already has answers here : How do I vertically center text with CSS? [duplicate] (38 answers) Closed 5 years ago . How is it possible to create a true center CSS div cross browser for example to use within a holding page? I have tried this 2007 css trick - How To Center an Object Exactly In The Center but as you can see from my JSFiddle of the code its not 100% center. HTML: <div class="center"> <p>Text</p> </div> CSS: .center{ position: fixed; top: 50%; left: 50%; margin-top:

Scaling an inline image from the absolute center of its parent?

只愿长相守 提交于 2019-12-06 16:54:40
I know this is another centering question but I think this is different to any of the others on StackOverflow. Before anyone says it yes I have searched for a solution but found nothing. To get my point across better I've mocked up an image to give you an idea of what I would like my image to do: http://cl.ly/1q143w1P2p19322s2L0s The problem I have a fluid, full browser width layout. For this question and to explain it better my image is set at 400% width (height calculated automatically to maintain its aspect ratio). So therefore the image will fill the entire screen (and more). Every method

How do I center a DIV in the exact center of a page using jQuery?

无人久伴 提交于 2019-12-06 16:32:31
I need to center a DIV in the exact center of a page using jquery. My CSS style for the DIV is as follows: #page-content #center-box{ position:absolute; width:400px; height:500px; background:#C0C0C0; border:1px solid #000; } and my jQuery for centering is as follows: windowheight = $(window).height(); windowwidth = $(window).width(); pagecenterW = windowwidth/2; pagecenterH = windowheight/2; $("div#page-content div#center-box") .css({top: pagecenterH-250 + 'px', left: pagecenterW-200 + 'px'}); This code does not invoke any action on my page when refreshed. What am I doing wrong? Try this:

Vertically center image thumbnails into fix-sized div

爱⌒轻易说出口 提交于 2019-12-06 14:53:01
问题 OK, I know this has been discussed to death and people got greenlit answers for their questions but none of them work for me. What I want to do is vertically center thumbnails, which are generated dynamically or loaded via AJAX into a div with a fixed size. In my case 200*200 pixel. Please go to this site: click here and click on for example the "Web" button. You'll see that all the thumbnails are or on top of their boxes. I really tried everything I could think of. The only option I know

Center Bootstrap Row and Spans

时光毁灭记忆、已成空白 提交于 2019-12-06 13:49:24
I'm trying to center a Row and the spans inside of it with bootsrap. You can see it in the footer here: http://www.divisionforty.com/wall/ I'd like the social networking icons to be on the left, copyright in the middle the powered by on the right, as it all is. footer code: <div id="footer"> <div id="footer-content"> <div id="footer-bottom" class="clear"> <div class="row" style="margin: 0 auto;"> <div class="span12" style="width:100%;"> <div class="span2" style="text-align:left;"> <a href="https://twitter.com/WallSpaceOttawa"><img alt="twitter" class="social" src="<?php bloginfo('stylesheet

Crop centered image inside div

时间秒杀一切 提交于 2019-12-06 13:18:38
I have a div containing an image (img) element, which extends for 100% width inside it. I would like to specify a maximum height for the div, and hide the parts of the image exceeding this height. But I also want to keep this image centered vertically inside the div to show only its central part. For example, if browser width is 1200px and image aspect ratio is 4:3, image should display (1200x900)px. But if we want to crop height to 300px only and center vertically, image should position at -300px inside the div (and the div should hide 0-300 and 600-900 of the image height). Similar thoughts

Center floating DIVs

十年热恋 提交于 2019-12-06 12:55:25
Im trying to center 3 floating DIVs. It works if I give the parent DIV display:table; and the child DIVs display:cell; which will then act like a table. Is there another way ? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Center Div</title> <style type="text/css"> #container { text-align:center; margin:0 auto; display:table; } #container div { float:left; padding:5px; display:cell; } </style> </head> <body> <div id="container"> <div style="background-color:yellow">Text 1</div> <div style="background-color:lightgreen">Text 2</div> <div style="background-color:lightblue