center

How does one have centered text and right-floating text on the same line, when everything has dynamic widths?

喜欢而已 提交于 2019-12-10 12:34:33
问题 I have a variable size block of text, which I would like centered in a div. The width of the div is a % of its parent element, and the height is defined by padding however tall the center text is. This is easily achieved via: <div style="width: 50%; padding: 15px; text-align: center;"> Lorem ipsum... </div> That works fine. But when I try to add the part on the right: <div style="width: 50%; padding: 15px; text-align: center;"> Lorem ipsum... <div style="float: right;">ASDF!</div> </div> then

Center div in page

对着背影说爱祢 提交于 2019-12-10 11:56:29
问题 I know this has been asked a thousand (million?) times, but for the life of me I can't figure out why I can't get a div to center on my page. Even with the HTML and CSS stripped down to the bare minimum. I'd appreciate it if someone could point out what I'm missing here. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style type="text/css"> div#branchSelect { margin: 0 auto; } </style> </head> <body> <div id="branchSelect"> <h4 class=

Why won't my Div center itself in its parent?

主宰稳场 提交于 2019-12-10 10:04:41
问题 I am making a header bar for a website. This header bar consists of 3 parts: The Back Button, The School Information, and The Login Button. The problem is that the center div, the School Information, will not center itself. I've tried everything I know how to do and nothing works. Here is my HTML and CSS: /* -- Button Bar -- */ .buttonbarframe { width: 100%; background-color: #F1F1F1; border-bottom: 1px solid #D5D5D5; box-shadow: 1px 1px 2px #D5D5D5; position: fixed; left: 0; right: 0; top: 0

How to center on HTML5?

帅比萌擦擦* 提交于 2019-12-10 04:38:52
问题 So i have this code here Which is the plans i will be providing on my website, but i have commented out one of the plans and now im looking to just display 3 plans, so how would i center all 3 of them as you can see by the picture, there more to the left? <!-- Row fuid--> <div class="row"> <!-- Item table --> <div class="col-sm-6 col-md-4 col-lg-3"> <div class="item_table"> <div class="head_table"> <h1>FREE</h1> <h2>£ 0.00 <span>/ Mo</span></h2> </div> <ul> <li class="color">2 GB HDD</li> <li

How to center ImageView in a toolbar?

狂风中的少年 提交于 2019-12-10 00:55:24
问题 Been trying to center a logo inside my toolbar. When i navigate to the next activity, the "up affordance" icon is present, and it will push my logo slightly to the right. How can I keep my logo at the center of the toolbar, without removing the up affordance icon? This is my toolbar tag <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap

How do You Center a TextView in Layout?

 ̄綄美尐妖づ 提交于 2019-12-10 00:38:20
问题 I have a complex layout, part of which features a value centered over a label, with + and - buttons on either side of the value. I want the value to center between the buttons, whether it is "1" or "99". It looks fine when it's a 2-digit number like "99", but when it's a single digit the number is left-justified. How do I properly center that value? Here's the portion of my layout that does this: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

Android TabHost Center active Tab

只愿长相守 提交于 2019-12-09 19:45:14
问题 Is it possible to change Android Tabs that if you press one, it comes to the center of the TabHost. Only 3 Tabs are visible, doesn't matter how many there are. Like in the Android 4.0 Google Music App! If it is, how would you do that? Thank you! 回答1: I did find the answer myself. If somebody else needs it, this should do it: final HorizontalScrollView mHorizontalScrollView; float scale = getResources().getDisplayMetrics().density; final double tabWidth = (int) (150 * scale + 0.5f); for (int i

How can I get the current zoom level in a UIScrollView?

醉酒当歌 提交于 2019-12-09 16:30:54
问题 In an attempt to create a workaround for centering an image in a UIScrollView and make it behave as Apple's Photos app does, I need to get the current zoom level and use the number to calculate the amount the image should be inset at each zoom level. (Note: I am aware that some programmers are centering an image in a scrollview by centering the image in a UIView that is the same size as the scrollview. This does not give good results and I am trying to find out how apple made it work in the

Android Button Place Image in center and text at bottom

倾然丶 夕夏残阳落幕 提交于 2019-12-09 14:27:25
问题 I want to place Image in the center and text just below it in a button, I tried to set android:gravity but could not set it properly,here is the image attached: below is my xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="10.0dip" android:paddingRight="10.0dip" android

How do I center floated list items?

旧街凉风 提交于 2019-12-09 11:29:25
问题 I have list items for my site nav that I need to center. I'm floating so that I can have padding on the list items...setting them to inline seems to eliminate top and bottom padding. <style type="text/css"> #nav { width:100%; } #nav ul { margin-right: auto; margin-left: auto; } #nav ul li { float: left; background-color: #333; color: #fff; padding: 15px; margin: 10px; } </style> <div id='nav'> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> </div> 回答1: By making the