I know I am supposed to set -fx-text-alignment: center; in order to achieve a center-aligned textarea.
#txtFaContent
{
-fx-text-alignment: center;
}
with txtFaContent being the ID of my textarea (as well as its variable name inside the controller). But it doesn't have any effect on the text alignment of my textarea (I played with right/left/center; but no success).
Have I missed anything?
Add style class in your TextArea.text:
TextArea textArea = new TextArea();
textArea.getStyleClass().add("centered-text-area");
Add .text in your CSS:
.centered-text-area .text {
-fx-text-alignment: center;
}
Related
With the Angular Material Table component, by default, the column headers on a table will left align, which is great:
However, if there isn't enough room for the header then the text wraps, which is fine except that the text then center aligns...
How do I make the text left align? I thought this would be straight forward, but I'm having issues. This also only appears to happen on headers with sorting, because if you remove the mat-sort-header directive from any of the header cells, things left align correctly.
I tried adding the following css class definition, but no luck:
.mat-sort-header-button {
text-align: left;
}
Here is the demo I'm playing around with.
The reason why your styles is not working is that Angular uses Emulated encapsulation be default so your styles are component scoped. That means that you can only apply class to element which is placed in component template directly. You can't style nested components.
To style elements from nested components you have to use ::ng-deep selector:
::ng-deep .mat-sort-header-button {
text-align: left;
}
Forked Stackblitz
There are other ways to solve it:
using encapsulation: ViewEncapsulation.None
using global styles
If anyone is still looking for global styling, then check this.
StackBlitz link for sort header alignment
Define below styles in style.css:
For text alignment in sort header or normal header
th.text-align-left,th.text-align-left .mat-sort-header-button {
text-align: left !important;
}
th.text-align-right,th.text-align-right .mat-sort-header-button {
text-align: right !important;
}
th.text-align-center,th.text-align-center .mat-sort-header-button {
text-align: center !important;
}
For Content Alignment in sort header
th.align-center .mat-sort-header-container {
justify-content: center;
}
th.align-right .mat-sort-header-container {
justify-content: flex-end;
}
th.align-left .mat-sort-header-container {
justify-content: flex-start;
}
And you can use these text-align-left, align-left etc classes in th
I am using a VBox in the left position of my parent layout BorderPane. I want to use a css file to change and use an image background on the left side of the BorderPane which contains my VBox. I have the following in my ccs file but cant manage it to work.
.vbox{
-fx-background-image: url("/ui/image11.jpg");
-fx-background-repeat: no-repeat;
-fx-background-position: center center;
-fx-background-size: 500 500;
}
.root{
-fx-background-color: #ecf0f1;
-fx-background-position: center center;
-fx-background-size: 500 500;
}
.button{
-fx-text-fill: #ecf0f1;
-fx-background-color: #455d7a;
-fx-position: center;
-fx-min-width: 150px;
-fx-transition-duration: 1;
}
With this css file, rules in .root and .button do apply but not on .vbox. How can I manage the backgrounds of the different sections in BorderPane.
I import the css file with the following line of code:
scene.getStylesheets().add(this.getClass().getResource("/styles/contentStyle.css").toExternalForm());
Is this the correct way? The css file is in another package.
VBox doesn't have a .vbox class selector defined. One way to fix this is to
set a styleclass on your VBox called .vbox, like this:
myVBox.getStyleClass().add("vbox");
but you would need to do that for each VBox in your application if you wanted them all to have that background.
See this question about HBoxs: JavaFX: Styling application with CSS Selectors for more info.
I am using ReadMore.js on my website, it is a plugin that creates a "readmore/close" button that toggles the visibility of content.
Currently the 'read more' button is aligned to the left under the article it collapses. An example of this code is on http://jedfoster.com/Readmore.js/. I would like the button to align to the right.
I have looked through the documentation, there doesn't seem to be any configuration that allows me to change the alignment. The code that is produced by the script doesn't have a class attached:
Read More
Is there a way of creating a class that targets the 'data-readmore-toggle'?
I found a way:
[data-readmore-toggle^="rmjs"] {
text-align: right;
}
This targets all the datatypes that begin with rmjs.
article + [data-readmore-toggle] {
text-align: right;
}
OR
[data-readmore-toggle] {
text-align: right;
}
Here is a fix
a.article.atn {
text-align: right;
}
Or
a{
text-align:right
}
I would like to replace horizontal line rendered by default by the <hr> tag with three asterisks (horizontally centered). If possible, I want to achieve this with pure CSS, specifically:
I don't want to touch my markup, there should be just plain <hr>, no helper divs or anything like this (because I'm styling Markdown files);
no background images;
no Javascript.
First I tried:
hr {
width: 0;
}
hr:before {
content: "***";
}
and it almost does the trick, but I want it centered, and have no idea how to center it.
Browsers display <hr>s using borders, so:
hr {
border: none;
}
hr::before {
content: '***';
display: block;
text-align: center;
}
Slap a text-align:center on your psuedo-element.
I've been fiddling around and trying to figure out how to make the text from within a WordPress menu list bigger and I just can't figure it out.
The URL is here
http://www.playstoresales.com/top-charts/
And I just want the text in the main list(games, top free games, top adventure games, top action games, etc) to be bigger.
I can't seem to find out which CSS class(or whatever) that I should be targeting, and what the syntax for it is.
Depends on the level of control but a nuclear option that would change the font size of every li element that has a CSS class of .menu-item would be:
.menu-item {
font-size: 24px;
}
For a little more control you could target that specific menu with an additional CSS class. I see you already have class (.menu-=top-charts-container) and id (#menu-top-charts) to hook onto.
/* all elements with .menu-item class */
.menu-item {
font-size: 18px;
}
/* only elements with .menu-item within #menu-top-charts element */
#menu-top-charts .menu-item {
font-size: 24px;
}
I believe this should work:
.menu-item.parent > a { font-size: 30px; } /* Or whatever font you want */
That being said, you may want to try tagging all the links that you want to have bigger text with a css class, that way you can target the class instead of adding selectors.
Like this:
.main-link { font-size: 30px; } /* All hyperlinks you want to be bigger can have this class */
Targeting the anchor within the ul ID;
#menu-top-charts a {
font-size: 50px;
}