centering

Vertically center text in a 100% height div?

拟墨画扇 提交于 2019-11-26 23:00:06
问题 I am working with a div that is 100% of the parent divs height. The div only contains a single line of text. The div cannot have a fixed height. So my question is. How do I vertically center the line of text? I have tried using: display: table-cell; line-height:200%; If it is important the div is absolutely positioned. Current CSS .requests { position: absolute; right: 0; height: 100%; width: 50px; padding: 0 10px; background-color: #69A4B5; display: table-cell; vertical-align: middle; border

How to center a navigation bar with CSS or HTML?

家住魔仙堡 提交于 2019-11-26 22:59:07
问题 I am having difficulty with centering the navigation bar on this page. I tried nav { margin: 0 auto; } and a bunch of other ways, but I still can't center it. 回答1: #nav ul { display: inline-block; list-style-type: none; } It should work, I tested it in your site. 回答2: Add some CSS: div#nav{ text-align: center; } div#nav ul{ display: inline-block; } 回答3: If you have your navigation <ul> with class #nav Then you need to put that <ul> item within a div container. Make your div container the 100%

How can I center Twitter-Bootstrap 3 navbar links?

不羁的心 提交于 2019-11-26 21:00:07
问题 How can I center the buttons in the jsFiddle I set up so that the buttons are equally spaced and centered within and through-out the navbar? http://jsfiddle.net/3GQyq/3/ I have tried different methods such as display:inline-block;margin:0 auto; text-align:center; But I cannot get it to work. If you could give a little explanation instead of just fixing the CSS as I want to learn so I do not have to keep coming back here. EDIT: Just like how they are centered here ^. 回答1: Bootstrap 3 has a nav

Anchors := [akCenter]?

天大地大妈咪最大 提交于 2019-11-26 20:56:25
问题 How can I center a control within its parent? And how to keep it centered when the parent resizes? I know I could write a Parent.OnResize event handler to move the control manually, but not all container components have an OnResize event, and I would like to do this automatically. Is there an akCenter anchor? 回答1: The anchor akCenter does not exist. But you can mimic akRelative by setting the anchors property empty which results in relative movement of the control when the parent resizes.

How to horizontally center an unordered list of unknown width?

柔情痞子 提交于 2019-11-26 18:12:51
It is common to have a set of links in a footer represented in a list, such as: <div id="footer"> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </div> I want everything inside div#footer to be centered horizontally. If it was a paragraph, you would just easily say: p { text-align: center; } . Or if I knew the width of the <ul> I could just say #footer ul { width: 400px; margin: 0 auto; } . But how do you center the unordered list items without setting a fixed width on the <ul> ? EDIT: clarification - the list items should be next to

How to center a window on the screen in Tkinter?

混江龙づ霸主 提交于 2019-11-26 17:26:18
I'm trying to center a tkinter window. I know I can programatically get the size of the window and the size of the screen and use that to set the geometry, but I'm wondering if there's a simpler way to center the window on the screen. Wayne Werner You can try to use the methods winfo_screenwidth and winfo_screenheight , which return respectively the width and height (in pixels) of your Tk instance (window), and with some basic math you can center your window: import tkinter as tk from PyQt4 import QtGui # or PySide def center(toplevel): toplevel.update_idletasks() # Tkinter way to find the

center <IMG/> inside a <DIV> with CSS

江枫思渺然 提交于 2019-11-26 17:02:53
问题 I want to center image inside a div. The div has fixed width 300px. The image width is known only at runtime. It usually is bigger then 300px, so image should be centered and cut right and left. margin 0 auto does not work in this case. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type="text/css"> div{width:300px;border:1px solid red; overflow:hidden} img{ /* NOTE!!!! margin:auto; doesn't work

How can I vertically center text in a dynamically height div?

≯℡__Kan透↙ 提交于 2019-11-26 16:09:55
<body> <div style="position:absolute; height:100%; width:100%;"> <h1 style="text-align:center;">Text</h1> </div> </body> How can I vertically center the h1 tag inside of the div tag, no matter how tall the div element is? i.e. If the user changes his browser height, I want the h1 to vertically align in the center, according to the new height. Thanks. The best solution I've ever encountered is to make use of the display property and set the wrapper element as a table to allow the usage of vertical-align:middle on the element to be centered: See this working Fiddle Example ! HTML <body> <div>

How to horizontally align ul to center of div?

你。 提交于 2019-11-26 15:50:51
I am trying to center a <ul> inside a <div> . I tried the following text-align: center; and left: 50%; This is not working. CSS : .container { clear: both; width: 800px; height: 70px; margin-bottom: 10px; text-align: center; } .container ul { padding: 0 0 0 20px; margin: 0; list-style: none; } .container ul li { margin: 0; padding: 0; } I want the ul to be centered inside the container. Following is a list of solutions to centering things in CSS horizontally. The snippet includes all of them. html { font: 1.25em/1.5 Georgia, Times, serif; } pre { color: #fff; background-color: #333; padding:

How to horizontally center a floating element of a variable width?

微笑、不失礼 提交于 2019-11-26 15:17:35
问题 How to horizontally center a floating element of a variable width? Edit: I already have this working using a containing div for the floating element and specifying a width for the container (then use margin: 0 auto; for the container). I just wanted to know whether it can be done without using a containing element or at least without having to specify a width for the containing element. 回答1: Assuming the element which is floated and will be centered is a div with an id="content" ... <body>