center

How to find the element's x center coordinates and related window offset

十年热恋 提交于 2019-12-18 10:34:15
问题 i would like to retrieve the element offset starting from his own x center coordinates. how can i do it? Actually i can find the window offset of an element but it retrieves the coordinates from the border of the element like this: var _position = $(this).offset(); 回答1: You have to use offset() to get the top and left position, then add half of the height() and width() values to them. That gives the center coordinates. var $this = $(this); var offset = $this.offset(); var width = $this.width(

css centering dynamic div

余生颓废 提交于 2019-12-18 09:45:17
问题 I have a div #content where i on the run add left floated divs #block and there are divs with fixed width on either side of div (a) , #lcontent and #rcontent How do i get #content to remain at center when side divs have dynamic height and #content changes over time content should remain in center wether there are 2,3,4 or 100 #block inside it. But the #block should always be on the left of #content Only #lcontent, #rcontent and #block have fixed width html code <div id="contentcontainer">

Center VideoView in landscape mode

徘徊边缘 提交于 2019-12-18 09:25:18
问题 How can I center a VideoView in landscape mode? I tried this: on Manifest file I have : android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" and on my Activity I have this code: RelativeLayout.LayoutParams lv= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lv.addRule(RelativeLayout.CENTER_HORIZONTAL); myVideoView = new VideoView(this); myVideoView.setLayoutParams(lv); myVideoView.setVideoPath(Environment .getExternalStorageDirectory() + "

Center block vertically and horizontally with dynamic width and height

泄露秘密 提交于 2019-12-18 07:30:10
问题 I need to center an element both vertically and horizontally and the element can't have any fixed dimensions. The contents of the element must not be affected...meaning some elements will be text-align left, others center, they may be images, etc etc. Here's where I'm at currently: http://jsfiddle.net/Shpigford/BUbmz/ The width and height of the blue block changes dynamically based on the content and centers horizontally, which works fine. But what I now need to do is center the blue block

Vertically Centering content in html [duplicate]

笑着哭i 提交于 2019-12-18 07:24:50
问题 This question already has answers here : How to align a <div> to the middle (horizontally/width) of the page [duplicate] (27 answers) Center a DIV horizontally and vertically [duplicate] (7 answers) Closed 5 years ago . I am trying to vertically center a <div> within a <body> The reason I'm trying to do this is because I'm trying to design a website that is in the style of the Windows 8 Metro start screen Does anyone know how this can be done? 回答1: If you want center block verticaly you can

jQuery scrollTo - Center Div in Window Vertically

谁说我不能喝 提交于 2019-12-18 05:20:20
问题 I have a site that uses a fixed menu on the top of the page. When a link is clicked, it should scroll vertically so that the center of that target div aligns with the vertical center of the window, offset by the height of the header. - this is very important so that the div is centered no matter what the resolution of the monitor is I'm using jQuery and scrollTo, but can't figure out the math needed for this. Here's my attempt: function scrollTo(target) { var offset; var scrollSpeed = 600; if

How to center text vertically in HTML using CSS only

走远了吗. 提交于 2019-12-18 04:23:17
问题 I have a very simple HTML. Due to some limitations, I cannot modify the HTML content. I want to center the text vertically only using CSS. <html> <head>...</head> <body> <div>Oops, the webpage is currently not available.</div> </body> </html> Note that the size of the HTML can be variable. In addition, if the text cannot be displayed in one line, it should be broken into multiple lines. Is it possible? 回答1: I think vertical-align only works for content which is in a table. For your simple

center image in div with overflow hidden

天涯浪子 提交于 2019-12-17 22:57:42
问题 I have an image of 400px and a div that is smaller (the width is not always 300px as in my example). I want to center the image in the div, and if there is an overflow, hide it. Note: I must keep the position:absolute on the image. I'm working with css-transitions, and if I use position:relative , my image shakes a bit (https://web.archive.org/web/20120528225923/http://ta6.maxplus.be:8888/). jsfiddle http://jsfiddle.net/wjw83/1/ 回答1: You should make the container relative and give it a height

Recenter a Google map after container changed width

好久不见. 提交于 2019-12-17 22:26:41
问题 I have a google map set with the Javascript API V3. It's displayed in a div with a dynamic width, as a content pane slides up when we click on a marker. Everything works fine, but one thing: When the pane slides up, the width of the map is changed, and so the center is displaced to the right (the pane is on the left). It is really inconvienient especially for small resolutions, where you can't even see the center after the pane is open. I've tried the 'resize' trigger, but it doesn't seem to

Android : Locating the item at center position of the screen after selecting it ,In the horizontalscrollview

允我心安 提交于 2019-12-17 19:17:17
问题 I am trying to scroll item to the middle position of the screen after selecting it.I have used Horizontalscrollview and LinearLayout inside it to add item. I show in the XML XML <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <LinearLayout android:layout_width="match_parent" android