Questions tagged [text-alignment]
Most word processing programs give you the capability to change the text alignment of a block of text. This setting determines how the text is displayed horizontally on the page. The four primary types of text alignment include left aligned, right aligned, centered, and justified.
text-alignment
958
questions
2340
votes
51
answers
764k
views
Vertically align text to top within a UILabel
I have a UILabel with space for two lines of text. Sometimes, when the text is too short, this text is displayed in the vertical center of the label.
How do I vertically align the text to always be ...
234
votes
6
answers
150k
views
`col-xs-*` not working in Bootstrap 4
I have not encountered this before, and I am having a very hard time trying to find the solution. When having a column equal to medium in bootstrap like so:
<h1 class="text-center">Hello, world!...
173
votes
10
answers
349k
views
Under which circumstances textAlign property works in Flutter?
In the code below, textAlign property doesn't work. If you remove DefaultTextStyle wrapper which is several levels above, textAlign starts to work.
Why and how to ensure it is always working?
import ...
124
votes
1
answer
105k
views
How to left align text in annotate from ggplot2
My example is:
qplot(mtcars$mpg) +
annotate(geom = "text", x = 30, y = 3, label = "Some text\nSome more text")
How do I get the text here to be left aligned? So that the 'Some's line up with each ...
112
votes
26
answers
235k
views
How to set top-left alignment for UILabel for iOS application?
I have added one label in my nib file, then its required to have top-left alignment for that lable. As I am providing text at runtime so its not sure that how much lines there are.
So if text contains ...
88
votes
7
answers
58k
views
How to center a two-line text in a TextView on Android?
I want to let it looks like this:
| two |
| lines |
Here is the current layout, not working at all.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="...
86
votes
4
answers
79k
views
Text/Layout Alignment in Android (textAlignment, gravity)
What's the difference between android:textAlignment and android:gravity?
77
votes
7
answers
160k
views
C++ alignment when printing cout <<
Is there a way to align text when printing using std::cout? I'm using tabs, but when the words are too big they won't be aligned anymore.
Sales Report for September 15, 2010
Artist Title Price ...
71
votes
3
answers
139k
views
How can I horizontally center a button element in a div element?
I don't want to add CSS to my div element (e.g. <div style="text-align: center;">).
I only want to add CSS code to the button element.
<div>
<button>Button</button>
...
55
votes
3
answers
159k
views
Align text in JLabel to the right
I have a JPanel with some JLabel added with the add() method of JPanel. I want to align the JLabel to the right like the image below but I don't know how to do that. Any Idea? Thanks!
49
votes
8
answers
72k
views
Aligning text in bootstrap tooltip
Bootstrap tooltip aligns text to the middle by default. I'd like to align to the left. Is there any nice way of doing this within HTML, instead of modifying CSS file?
Here is my sample code:
<p ...
47
votes
10
answers
104k
views
set view text align at center in spinner in android
view-text-in-the-center-of-the-spinner-when-select-from-the-drop-down-list
I want to align the view text of spinner to center. I google it but didn't find anything, does anybody knows about this? any ...
47
votes
2
answers
35k
views
How to center a text using PDFBox
My question is very simple: how can I center a text on a PDF, using PDFBox?
I don't know the string in advance, I can't find the middle by trial. The string doesn't always have the same width.
I ...
45
votes
2
answers
31k
views
Trouble left-aligning UIButton title (iOS/Swift)
I'm having a problem left-aligning a UIButton's text. I also tried changing it to .Right but it still stays centered. I also tried aButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, ...
43
votes
4
answers
80k
views
Python: String Formatter Align center [duplicate]
print('%24s' % "MyString") # prints right aligned
print('%-24s' % "MyString") # prints left aligned
How do I print it in the center? Is there a quick way to do this?
I don't want the text to ...
41
votes
12
answers
115k
views
text-align justify not working
I'm trying to justify the text within this p tag so that it perfectly fits the width of the p.
<p align="justify" style="text-align: justify !important; color:#fff; margin:0px; font-weight:bold; ...
38
votes
6
answers
103k
views
Difference between <span> and <div> with text-align:center;?
I don't understand this:
I have tried to center the text-align of a HTML <span> tag but it did nothing...
With the <div> tag, everything worked. Same sittuation with setting margin: 0px ...
35
votes
6
answers
48k
views
How can I centre left aligned text even when it wraps?
I need to centre a block of left aligned text within a div, but I need the visual width of the text block to be centred not the block itself.
In many cases this may be the same thing, but think of a ...
31
votes
9
answers
48k
views
text-align is not working on safari <select>
I have tried aligning the text in the <select> element to the right or the center in safari. But nothing worked. text-align:center; worked in all browsers except safari. direction:rtl; and dir="...
29
votes
16
answers
21k
views
vertically align text in a CATextLayer?
I am working on a CATextLayer that I want to use in both Mac and iOS. Can I control the vertical alignment of the text within the layer?
In this particular case, I want to center it vertically -- ...
28
votes
2
answers
72k
views
Align text inside a plot
I am an R newbie and had a question. I am trying to place some text into an R plot. Here's some code using the brightness dataset in the UsingR package.
library(UsingR)
brightness
MyMean ...
27
votes
1
answer
14k
views
Jetpack Compose align input text in TextField
I would like to achieve similar behaviour with TextField from Jetpack Compose like from old school XML layout:
<EditText
android:id="@+id/some_id"
android:layout_width="...
26
votes
3
answers
148k
views
CSS text-align not working
I have this css code here
.navigation{
width:100%;
background-color:#7a7a7a;
font-size:18px;
}
.navigation ul {
list-style-type: none;
margin: 0;
}
.navigation li {
float: ...
25
votes
6
answers
13k
views
How can I place images side-by-side in restructured text?
Is there a way to put 2 different images on the same "line", so, side-by side?
I know there is the :align: option, but if I put two images, the first with :align: left and the second with :align: ...
23
votes
6
answers
52k
views
How do I make text run top-to-bottom in CSS?
Does anyone know how to make text align top-to-bottom in a div.
SO won't even let me demonstrate it . . . I just want the letters to stack on top of each other in a vertical line down the page like ...
23
votes
3
answers
51k
views
Set default alignment for cells in QTableWidget
I know you can set the alignment for each item using:
TableWidget->item(0,0)->setTextAlignment(Qt::AlignLeft);
However I would like to set a default alignment for all the cells in order to do ...
22
votes
3
answers
140k
views
How to justify text in label in Tkinter
In Tkinter in Python:
I have a table with a different label. How can I justify the text that is in the label? Because It is a table and the texts in different labels come together!
from tkinter ...
22
votes
3
answers
10k
views
Multiple alignment in TextView?
I have a TextView like below.
I used this code to set gray color for a part of the text.
// Prepare result text.
final String resultText = text + "\n\n" + dictionaryName;
final SpannableString ...
22
votes
2
answers
113k
views
Latex: Text cannot be placed below image
I'm having a problem with an image and some text. I have this code:
Some text...\\
\begin{figure}[ht]
\centering
\includegraphics[scale=0.75]{picture.jpg}
\caption{The caption}
\label{fig:picture}...
21
votes
2
answers
41k
views
Setting JButton text to align to the left?
I previously had a JLabel, that I wanted to be click-able. The easiest way I found to do this was make it a JButton and using the following code. It now looks like a JLabel
button.setBorder(...
21
votes
2
answers
38k
views
Python Kivy: Align text to the left side of a Label
I read the docs, and still don't know how to align the text inside a Kivy-Label to its left side. The text is centered from default. A halign = "left" didn't help.
Sorry, if the solution is obvious, ...
20
votes
2
answers
13k
views
Difference between text-align: end and right
What is the difference between text-align: end; and text-align: right;?
When I use either one I get the same result, but is there any differences?
20
votes
2
answers
26k
views
How to align QPainter drawText around a point, not a rectangle?
I want to set text drawing alignment using one point as coordinate, not a rectangle.
As far as I understand QPainter::drawText allows to set text alignment only when I pass coordinates as rectangle.
...
17
votes
7
answers
38k
views
Justify Text in a HTML/XHTML TextArea
I am currently trying to justify text in a textarea, unfortunately the CSS:
text-align: justify;
Doesn't work on the text like center, left and right do. I've tried this in both Firefox 3 and IE 7 ...
16
votes
6
answers
107k
views
How to print a table of information in Java
I'm trying to print a table in Java and I was wondering what is the best way to do this?
I've tried printing new lines and using \t to make contents line up but it doesn't work. Is there a method ...
16
votes
7
answers
60k
views
How to make text vertically and horizontally center in an HTML page
I have some experience with Java , C , databases , networking etc..But anything related with Html I am a begginer.The only thing that I am looking for is to center two words in the middle of the page(...
16
votes
1
answer
3k
views
Pycharm code reformatting: align lines by operator
In Jetbrains Pycharm (Professional, 2016.1), is there a way (built in or third-party) to modify the code style in python to align consecutive lines by an operator, particularly an assignment one? For ...
15
votes
6
answers
16k
views
Print a data frame with columns aligned (as displayed in R)
I have the following data frame in R:
> dframe
Mean Median
Candidates 85.68 60
NonCands 9.21 4
Multi 27.48 17
Mono 4.43 3
Multi ...
15
votes
4
answers
46k
views
Why can I not right-align an element with display: block and width: X?
Total n00b question here (at least to the CSS elite):
Why is it that an element with both display: block; and a value for width does not seem to fall in line with the text-align property of its ...
15
votes
1
answer
8k
views
Space at end of text not visible in right-aligned UITextField
I have a right-aligned UITextField. Initially spaces did not appear at the end of the text when editing. This I solved using this: replacing @" " with the non-breaking "\u00a0".
The above, however, ...
14
votes
3
answers
8k
views
SwiftUI - how to change text alignment of label in Toggle?
Code for Toggle in SwiftUI is this:
Toggle(isOn: $vibrateOnRing) {
Text("Vibrate on Ring")
}
This will produce a toggle button with text label looking like this:
Vibrate on Ring | [--...
13
votes
1
answer
29k
views
Horizontally center <p> within a div while keeping the text left-aligned
I have multiple divs with a fixed width containing <p> tags which contain various lengths of text.
I want this text to remain left-aligned but if the text does not take up as much space as the ...
13
votes
3
answers
10k
views
Right align text in HTML input field
I have an HTML tag with a short maxlength but a long value attribute. I'd like the displayed text to show the end (right side) of the text, rather than the start (left side).
<input maxlength=10 ...
13
votes
3
answers
295
views
Unable to center text in IE but works in firefox
Text inside td elements need to be centered except for Summary and Experience. This only appears to work in Firefox/chrome. In IE8 all td text are displayed as left-justified. No matter what I try it ...
12
votes
9
answers
4k
views
How does one have centered text and right-floating text on the same line, when everything has dynamic widths?
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. ...
12
votes
3
answers
4k
views
Text align problem when using Arabic font
The screenshot below displays my problem.
The first EditText shows a hint in Arabic which is shifted upwards, now the second EditText is just for reference which shows the English version completely ...
11
votes
6
answers
39k
views
Justify text in an Android app using a WebView but presenting a TextView-like interface?
I'm looking for a simple way to forget that I'm using a WebView to have justified text in my TextView. Has someone made a custom view for this? I'm well aware that I can do something like this:
...
11
votes
11
answers
25k
views
Xamarin Forms Label - Justify?
I just wanted to ask if there is any way to justify text in a Label. I am using Xamarin Forms Xaml.
Thanks.
UPDATE:
As for now, it is not possible to justify text. Most of the answers were about ...
11
votes
5
answers
40k
views
Text align of an unordered list item
I'm wondering if there's any way to make the text of an unordered list item appear as a "column" by the side of the standard disc/dot list item icon? Made a pair of screenshots:
This is how it looks ...
10
votes
4
answers
32k
views
Swift : align UILabel text in the top rather in the middle
I want the UILabel to start from the top even if the text is short it seems that
NSTextAlignment doesn't work
cell.textContent.text = comments[indexPath.row]
cell.textContent.textAlignment =
func ...