How to set width of paper-textarea in Polymer 1.0? - css

Does anybody knows how to set the width of a paper-textarea? Using CSS selectors in Polymer 1.0 style tags seems not to work at all. The paper-textarea element is composed with paper-input-container. So I tried to do the following:
<style>
paper-textarea + paper-input-container {
min-width: 324px;
width: 324px;
margin-right: 24px;
}
paper-textarea > paper-input-container {
min-width: 324px;
width: 324px;
margin-right: 24px;
}
paper-textarea paper-input-container {
min-width: 324px;
width: 324px;
margin-right: 24px;
}
</style>
Neither of the CSS selectors above worked in my custom element.

<style>
:root {
--paper-input-container: {
min-width: 324px;
width: 324px;
margin-right: 24px;
};
}
</style>
Will do the trick. It will style every polymer element that makes use of a paper-input-container (like paper-textarea) to the above width and margin.

Related

Root class is not read by SASS, only those with ampersand are

I have a sass/css class with an ampersand, this is used in conjunction with VueJS. What I was wondering is that the CSS attribute assigned on the ampersand is working but the root element itself isn't detected by the browser.
<style lang="scss" scoped>
.curved-input {
border-radius: 5px;
height: 50px;
margin-right: 1rem;
&__lg {
width: 300px;
}
&__sm {
width: 150px;
}
}
</style>
Here's the explanation, the browser seem to detect the width: 300px or width: 150px but not the border-radius, height, margin-right.
<input name="city" class="curved-input__lg" type="text" placeholder="Palau Ujong, Singapore"/>
The textbox width changed but other attributes are not read by the browser when you look at them on the browser tools. Am I missing something here?
My goal is not to code it as class="curved-input curved-input__lg but rather only use curved-input__lg or curved-input__sm while inheriting the parent attributes (curved-input).
You could use #extend to avoid adding additional classes to your markup or (some) duplicate code, if that is your goal.
.curved-input {
border-radius: 5px;
height: 50px;
margin-right: 1rem;
}
.curved-input {
&__lg {
#extend .curved-input;
width: 300px;
}
&__sm {
#extend .curved-input;
width: 150px;
}
}
Which would generate the following CSS
.curved-input,
.curved-input__sm,
.curved-input__lg {
border-radius: 5px;
height: 50px;
margin-right: 1rem;
}
.curved-input__lg {
width: 300px;
}
.curved-input__sm {
width: 150px;
}
This is because you have to declare the curved-input class as well. So your class attribute will look like class="curved-input curved-input__lg".
If you'd write out your CSS in full you'll get something like this:
.curved-input {
border-radius: 5px;
height: 50px;
margin-right: 1rem;
}
.curved-input__lg {
width: 300px;
}
.curved-input__sm {
width: 150px;
}
With this in mind you'll see that you have to add the class curved-input as well.
Well if you want to write it like that, try to change the first line to:
[class*="curved-input"]

Margin-right browser

Thanks to everyone, I am Italian, sorry for my English, I would like a clarification:
Why do not all browsers see margin-right, while developer tools have margin-right? (Firefox does not show margin-bottom, in addition to margin-right).
CSS
html
{
background-color:gold;
width: 100%;
height: 100%;
padding: 6px;
border: solid black 10px;
margin-top: 10px;
margin-right: 50px;
margin-bottom: 10px;
margin-left: 20px;
}
In the box model I have the margin-right, in the browser it is not considered.
Chrome browser and developer tools box-model:
Your box is over-constrained
CSS 2.2 says:
'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
If all of the above have a computed value other than 'auto', the
values are said to be "over-constrained" and one of the used values
will have to be different from its computed value. If the 'direction'
property of the containing block has the value 'ltr', the specified
value of 'margin-right' is ignored and the value is calculated so as
to make the equality true. If the value of 'direction' is 'rtl', this
happens to 'margin-left' instead.
From that, you can see that browsers automatically adjust the right margin, overriding the setting you give it.
You should take off the width from your css. since you are using margin, you are already telling the browser to only show a space of what you have allowed. It does not affect the height cos the height is pretty much infinite.
So you should have something like this
html
{
background-color:gold;
height: 100%;
padding: 6px;
border: solid black 10px;
margin-top: 10px;
margin-right: 50px;
margin-bottom: 10px;
margin-left: 20px;
}
Browsers do not always handle all css properties on the html element consistently because it has no parent. If I'm understanding what you want correctly, I'd recommend this if you want to avoid a wrapper div, but it might be a bit unstable:
* {
box-sizing: border-box
}
html {
background-color:gold;
width: 100%;
height: 100%;
padding: 10px 50px 10px 20px;
margin: 0;
}
body {
width: 100%;
height: 100%;
padding: 6px;
border: solid black 10px;
margin: 0;
}
See this working example
Alternately you can use a wrapper div and avoid doing anything to the HTML tag other than normalizing it (this is what I would recommend):
<html>
<body>
<div class="main">
<!-- All your content -->
</div>
</body>
</html>
* {
box-sizing: border-box
}
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
body{
background-color:gold;
padding: 10px 50px 10px 20px;
}
div.main {
width: 100%;
height: 100%;
padding: 6px;
border: solid black 10px;
margin: 0;
}
As shown here

Cannot add CSS attributes to <span>

In a CSS file I have the following rules:
div.breadcrumbs span {
position: relative;
left: -120px;
height: 16px;
line-height: 16px;
margin: 0 20px;
overflow: hidden;
}
div.breadcrumbs img {
margin: 0 -20px;
padding: 5px 5px 0px 5px;
}
div.breadcrumbs a {
color: #88263F;
font-weight:bold;
}
The rules for img and a work, but not for span.
Also something does not work like
span {
display: none;
}
At the moment I have no clue how to debug this.
In principal, your posted CSS works.
If your HTML looks like this...
<div class="breadcrumbs">
These are <span>breadcrumbs</span> in a line...
</div>
and this is your CSS:
div.breadcrumbs span {
position: relative;
left: -120px;
height: 16px;
line-height: 16px;
margin: 0 20px;
overflow: hidden;
}
span {
display: none;
}
then the span element is not shown as you intended.
See demo at: http://jsfiddle.net/audetwebdesign/qyu5A/
You may have other problems such as other CSS rules that are conflicting and preventing the display: none property from working correctly.
There is nothing wrong with the positioning of an inline element, but you may not get exactly what you expect depending on the line height and surrounding content.
You may want to learn more about how the CSS cascade and specificity work.
Reference: http://www.w3.org/TR/CSS2/cascade.html#cascade
Note: The height property is ignored for inline elements.
Thank you for your hints, especially the fiddle!
Playing around with it I found the following code snippet also in the CSS file:
body.home div.breadcrumbs span { position:relative; left:0; }
Placing "div.breadcrumbs span" after this and deleting "position: relative;" it works as exspected.

Target certain CSS Classes with Gridster Plugin

I'm using the Gridster plugin, where columns width are defined like this:
[data-sizex="12"] { width: ... }
[data-sizex="11"] { width: ... }
[data-sizex="10"] { width: ... }
....
I have 2 questions about this;
What kind of CSS classes are these? I have never done/seen anything like this, especially in CSS.
If I want to select all the columns from 1-12, how do I use the code? Typically I'm using something like [class*=".."] this. I don't think so I can get a format like this for the above scenario.
1) These are CSS attribute selectors, to be specific these are Attribute presence and value selectors
2) If you want to select all the columns you don't have to use attribute selectors, just apply the CSS to the element. Well, for gridster plugin can replace .grid with .gs_w { }, .gs_w[data-sizex="12"]{ } and so on in the demo jsfiddle.
.grid{
/* Applies to all */
background: #808080;
color: #fff;
border: 1px solid #eee;
padding: 5px 10px;
}
.grid[data-sizex="12"]{
width: 720px;
}
.grid[data-sizex="11"]{
width: 710px;
}
.grid[data-sizex="10"]{
width: 700px;
}
.grid[data-sizex="9"]{
width: 690px;
}
.grid[data-sizex="8"]{
width: 680px;
}
.grid[data-sizex="7"]{
width: 670px;
}
.grid[data-sizex="6"]{
width: 660px;
}
.grid[data-sizex="5"]{
width: 650px;
}
.grid[data-sizex="4"]{
width: 640px;
}
.grid[data-sizex="3"]{
width: 630px;
}
.grid[data-sizex="2"]{
width: 620px;
}
.grid[data-sizex="1"]{
width: 610px;
}
Demo Here

why are the inherit css properties lost?

demo url: http://linjuming.pydra.org/zc_up/index.php?main_page=index&cPath=1_2
I am using oocss css framework in my site. A strange question comes out.
.complex .tl, .complex .tr {
height: 32000px;
margin-bottom: -32000px;
width: 10px;
}
These code is from stylesheet_010_oocss.css.
But not the same inherited by two place. why this happend?
Properties of Hight and Width in .complex .tl, .complex .tr rules are lost in <div class="sort_line s_box_sort_line complex"> ... </div> cause it properties are re-rules in your css in lowest posisition. Check this out:
/*in LINE 85 */
.complex .tl, .complex .tr {
height: 32000px;
margin-bottom: -32000px;
width: 10px;
}
/*in LINE 1696 */
.r_box_2 .tl, .r_box_2 .tr, .r_box_2 .bl, .r_box_2 .br {
height: 6px;
width: 6px;
}
/*in LINE 2116 */
.s_box_sort_line .tl {
background-position: -320px -320px;
height: 32000px;
width: 10px;
}
We are know css codes are rendered from top to bottom. That's why the code that will be used is the most recent code (lowest position).

Resources