HTML & CSS Diamond-Shaped Containers [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed yesterday.
Improve this question
I have tried multiple ways, but I’ve been running into issues attempting to make a container with diamond shaped edges on either side with the corner rounded, as well as another one with the diamond shape inverted. Similar to my sketch:
Optimally, the solution would only need HTML & CSS, with a different color border and fill. I would definitely be open to alternative solutions if that would include SVG, for example.
Thanks!
I have tried to create a mask with SVGs, but I could not find a way to add a border and a separate fill, as well as containing text inside it, and there were scale issues too (I’d like it only to scale horizontally, not vertically when width changes.)

You can achieve this using the ::before and ::after psuedo-elements in CSS relatively easily. The second one (with non-inverted triangles) is slightly less verbose than the first example, but both are achievable using a single HTML element and some creative CSS.
Please note that you might need to modify some of the pixel dimensions to suit your needs, but the following should achieve what you need:
.label {
background: red;
border: 2px solid #000;
color: #fff;
display: inline-block;
font-family: sans-serif;
margin: 0 30px;
padding: 10px 50px;
position: relative;
text-transform: uppercase;
}
.label::before,
.label::after {
aspect-ratio: 1/1;
background-color: #fff;
border: 2px solid #000;
content: '';
display: block;
height: 28px;
position: absolute;
overflow: hidden;
transform: rotate(45deg);
top: 4px;
}
.label::before {
border-bottom: none;
border-left: none;
left: -16px;
}
.label::after {
border-top: none;
border-right: none;
right: -16px;
}
.label--inverse::before,
.label--inverse::after {
background: inherit;
border: inherit;
}
.label--inverse::before {
border-top: none;
border-right: none;
left: -17px;
}
.label--inverse::after {
border-left: none;
border-bottom: none;
right: -17px;
}
<span class="label">Text</span>
<span class="label label--inverse">Text</span>

Related

How to make p-dropdown placeholder go up? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 months ago.
Improve this question
I've p-dropdown, and i need to make its placeholder to going up, when i choose one of the sort options, like on screenshots. Is there any way to achieve it with p-dropdow? Cause when i just add placeholder="Sort by" to p-dropdown, it disappears, when i choose sort options
You can do this with raw html and css as follows. You might be able to adapt it to suit your needs.
.input-container {
display: inline-block;
padding: 0.5rem 0.5rem;
position: relative;
border-radius: 0.25rem;
border: 1px solid lightgray;
}
.input-container>label {
display: none;
font-size: 0.6rem;
position: absolute;
background-color: white;
left: 0.5rem;
top: -0.4rem;
padding-inline: 0.25rem;
}
.input-container:focus-within {
border: 1px solid blue;
box-shadow: 0px 0px 8px 0px #0000ff;
}
.input-container:focus-within>label {
display: inline-block;
}
.input-container:focus-within input::placeholder {
opacity: 0;
}
.input-container>input {
outline: none;
border: none;
}
<div class=input-container><label id='placeholder-text' for='cats'>Choose a cat</label>
<input id='cats' placeholder='Choose a cat' type="text" list="catoptions" />
<datalist id="catoptions">
<option>Tiger</option>
<option>Lion</option>
<option>Jaguar</option>
<option>Kitten</option>
</datalist>
</div>

How to cover image/text with another one [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new in CSS and HTML but I creating website where I need to cover text or picture with another one. I made example in Photoshop what exactly I need:
A solution based on css shadow:
h1 {
font-family: cursive;
text-shadow: -10px -10px 0px rgba(150, 150, 150, 1);
}
<h1>Lorem Ipsum<h1>
Online tools like : https://css3gen.com/text-shadow/ could help you to construct right text-shadow property
The code is self explanatory, Nevertheless if any question leave a comment.
Text
Using text-shadow less flexible for instance the duplicated the text will always be behind the actual text, If we want to reverse this we will have to align the shadow as the actual text and the actual text as the shadow which is a lot janky and not dynamic.
p {
margin: 2rem;
border:1px solid red;
padding:10px;
display:inline-block;
}
p:hover {
text-shadow: -5px -5px red;
}
<p>Lorem</p>
Using pseudo-element highly flexible, Can place the text anywhere, Drawback is must provide the text as an attribute or a CSS variable
p {
margin: 2rem;
padding: 10px;
display: inline-block;
position: relative;
font-size:1.3em;
}
p:before {
color: red;
position: absolute;
top: 40%;
left: 40%;
width:100%;
}
p:nth-child(1):hover:before {
content: attr(data-text);
}
p:nth-child(2):hover:before {
content: var(--data-text);
}
<p data-text="attribute">attribute</p>
<p style="--data-text:'CSS variables';">CSS variables</p>
Image:
[box] {
width: 300px;
height: 300px;
background: url(https://picsum.photos/300);
position: relative;
}
[box]:hover:before {
content: '';
background: inherit;
width: 100%;
height: 100%;
top: 25%;
left: 25%;
position: absolute;
}
<div box></div>

If I put a <span> on a new line, stars will change position [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Hi I have following code:
.fotoRating {
color: #c5c5c5;
font-size: 50px;
position: relative;
text-shadow: 0px 1px 0 #a2a2a2;
}
.fotoRating .selectedStars {
color: #e7711b;
position: absolute;
top: 0;
overflow: hidden;
}
<div class="fotoRating">
<span>★</span><span>★</span><span>★</span><span>★</span><span>★</span>
<div class="selectedStars" style="width:150px;">
<span>★</span><span>★</span><span>★</span><span>★</span><span>★</span>
</div>
</div>
When I put span on a new line, the stars will break: http://jsfiddle.net/mozkomor05/6hkpj0L4/1/
I think there is a small mistake, but I can't find it.
The set width on your selected stars container is causing the characters to break into another line to fit. If you want to prevent line-breaks, add this rule to .selectedStars
white-space: nowrap;
https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
If you simply want to have different colors on the stars, you don't need two rows of them. You can just add a class to each star as needed:
.fotoRating {
color: #c5c5c5;
font-size: 50px;
text-shadow: 0px 1px 0 #a2a2a2;
}
.is-selected {
color: #e7711b;
}
<div class="fotoRating">
<span class="is-selected">★</span>
<span class="is-selected">★</span>
<span class="is-selected">★</span>
<span>★</span>
<span>★</span>
</div>
While #webdevdani approach works, it doesn't give the same result. Which is why I suggest this:
.fotoRating span {
display: table-cell;
}
This way the browser thinks they're cells and ignore the white space between the elements, while preserving the functionality
Here you go: http://jsfiddle.net/6hkpj0L4/4/
You need a fixed height on .selectedStarts. When you decrease the width to show a fewer number of stars, the stars are wrapping and your container is defaulting to height: auto; therefore showing all it's content.
Using a fixed width (here I used 70px) in combination with the overflow: hidden; which you already had in place does the job.
.fotoRating {
color: #c5c5c5;
font-size: 50px;
position: relative;
text-shadow: 0px 1px 0 #a2a2a2;
}
.fotoRating .selectedStars {
color: #e7711b;
position: absolute;
top: 0;
overflow: hidden;
height; 70px;
}
<div class="fotoRating">
<span>★</span><span>★</span><span>★</span><span>★</span><span>★</span>
<div class="selectedStars" style="width:150px;">
<span>★</span><span>★</span><span>★</span><span>★</span><span>★</span>
</div>
</div>

How to display multiple triangles using a pseudo element on a th table header [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to add two triangles using pseudo elements after the text in a table header cell. You guessed it, they would represent that the column is sortable. Of course, I can do that using a background image but I want to avoid that traditional solution.
I can add one triangle using the pseudo element :after. That's easy. I cannot use pseudo element :before to add the other triangle because it is placed before the text in the "th" element. If I have to position it, using the :before pseudo element, to be placed after the text, that will not work as a generic solution because each column header has, of course, different text.
Any idea on how to get around this?
DEMO: http://jsfiddle.net/7Wfc8/
HTML
<table>
<tr>
<th>Short</th>
<th>Really much longer</th>
</tr>
</table>
CSS
th {
border: 1px solid red;
padding-right: 30px;
position: relative;
}
th:after,
th:before {
content: " ";
display: block;
height: 0;
width: 0;
border: 5px solid transparent;
position: absolute;
right: 5px;
}
th:after {
top: -2px;
border-bottom-color: lime;
}
th:before {
top: 10px;
border-top-color: lime;
}
Here's a FIDDLE
<table>
<tr>
<th>Text</th>
<th>Text</th>
</tr>
</table>
th {
width: 160px;
padding: 5px;
border: 1px solid #999;
}
th:after {
display: inline-block;
float: right;
width: 10px;
line-height: 11px;
font-family: sans-serif;
font-size: 12px;
color: #0296cc;
content: '▲ ▼';
}

How to remove resize option present at the right bottom-corner of the textarea?

I'm trying to remove dots in a textarea which are present at the bottom-right corner.
Here's an example of what I mean (from Chrome):
How to remove those diagonal lines?
Just add in your CSS file
textarea { resize: none; }
Later (2019) edit:
Related to this answer of mine and the rising number of GitHub code search results on resize: none declarations applied to textarea elements, I wrote some lines on why I think CSS resize none on textarea is bad for UX:
Very often, the textarea is limited to a number of rows and columns or it has fixed width and height defined via CSS. Based solely on my own experience, while answering to forums, writing contact forms on websites, filling live chat popups or even private messaging on Twitter this is very frustrating.
Sometimes you need to type a long reply that consists of many paragraphs and wrapping that text within a tiny textarea box makes it hard to understand and to follow as you type. There were many times when I had to write that text within Notepad++ for example and then just paste the whole reply in that small textarea. I admit I also opened the DevTools to override the resize: none declaration but that’s not really a productive way to do things.
from https://catalin.red/css-resize-none-is-bad-for-ux/
So you might want to check this out before adding the above to your stylesheets.
It is as simple as the following code. Just give the textarea the style resize: none
<textarea style="resize: none"></textarea>
html
sass
textarea {
position: relative;
z-index: 1;
min-width: 1141px;
min-height: 58px;
}
.resizer {
position: relative;
display: inline-block;
&:after {
content: "";
border-top: 8px solid #1c87c7;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
-webkit-transform: rotate(-45deg);
z-index: 1;
opacity: 0.5;
position: absolute;
bottom: 1px;
right: -3px;
pointer-events: none;
}
}
.arrow-resizer-textarea {
height: 0;
width: 0;
border-top: 8px solid #1c87c7;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
-webkit-transform: rotate(-45deg);
position: absolute;
bottom: 1px;
right: -3px;
pointer-events: none;
z-index: 2;
}