Form input with graphic background [closed] - html

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I would like to give users the opportunity to input some text in a few colored shapes. Is it a good strategy to design the shapes in (for instance) illustrator, export as svg and put the input tags (or textarea's) in the svg file?
Other ways of doing this?

This is a simple example of doing what you're looking for with CSS - a starting point for you to work from.
(The CSS can be simplified down but I kept it deliberately verbose so you can see what's going on and where)
.text {
display:block;
width: 60vw;
margin: 1rem 20vw;
}
.textleft {
display: inline-block;
width:49%;
margin: 1rem 0;
padding:0 9% 0 5%;
box-sizing: border-box;
}
.textright {
width:49%;
display: inline-block;
margin: 1rem 0;
padding:0 5% 0 9%;
box-sizing: border-box;
}
.txtarea {
width:100%;
color: #000;
height: 7rem;
font-size:1rem;
box-sizing:border-box;
padding:1rem;
border: none;
border-radius:2rem;
resize: none;
overflow:hidden;
}
#red {
background-color: #c00;
color: #eee;
}
#green {
background-color: #0c0;
}
#blue {
background-color: #33f;
color: #ccc;
}
#yellow {
background-color: #ff0;
}
<div class='text'><textarea id='red' class='txtarea' name='myinfo_top'>Some Words - Click on me to type into this text box!</textarea></div>
<div class='textleft'><textarea id='green' class='txtarea' name='myinfo_left'>Some Left Words</textarea></div>
<div class='textright'><textarea id='blue' class='txtarea' name='myinfo_right'>Some Right Words</textarea></div>
<div class='text'><textarea id='yellow' class='txtarea' name='myinfo_bottoms'>Some more Words</textarea></div>

Create div tag that will contain elements of height and width, if you want rounded corners you might use border-radius in CSS.
div{
width: 200px;
height: 200px;
border-radius: 15px;
background-color: blue;
}
Then you can add whatever text you would like. Its the best option, adding image in the background, it takes a lot more processing time than pure CSS.

Related

HTML & CSS Diamond-Shaped Containers [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 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>

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>

Float placement, not in the right 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 7 years ago.
Improve this question
i have my main "watchlisten" div, with everything you see so far inside, but for some apparent reason, i am unable to float my video image on the right side of my left arrow image, i have this as the code for CSS and HTML, i apologize for not having the images available for you to see them, but i want to float Video_1.jpg on the right of Left_watchlisten.jpg.
HTML for the whole watchlisten DIV
<div id="watchlisten">
<img src="Images/boxes.png" class="imageBoxes" />
<h2>Watch/Listen</h2>
<img src="Images/Left_Watchlisten.jpg" class="leftarrow"/>
<div class="wlblock">
<img src="Images/Video_1.jpg" height="75"/>
<p>action to cut leve crossing deaths</p>
</div>
</div>
CSS code for all the classes/id's/h2.
#watchlisten {
background-color: #EEEEEE;
float: right;
width: 380px;
position: relative;
top: -80px;
}
h2 {
color: #505050;
margin: 10px 0 10px 10px;
font-size: 1.8em;
}
.imageBoxes {
float: right;
max-height: 20px;
max-width: 100%;
margin: 12px 10px 0 0;
}
.leftArrow {
float: left !important;
border-right: 1px solid white;
}
.wlblock {
float: left;
}
i hope someone can help, i am a little stuck.
There is problem in your class naming
Your CSS code:
.leftArrow {
float: left !important;
border-right: 1px solid white;
}
Your HTML code:
<img src="Images/Left_Watchlisten.jpg" class="leftarrow"/>
Can you see the difference in class name?
Make the leftArrow, leftarrow in css or leftarrow in html to leftArrow.
It will work.

Aligning elements to the left and the right [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 8 years ago.
Improve this question
A client wants a navigation layout as shown below:
As you can see, it is made up of "main links" and "sub links". There can be any number of each, and the text content may change. The width of the menu container will change depending on the page size.
God bless the designers, who decided to align the left and right edges of these links, and keep a consistent amount of space between each one. The client is adamant that this is how the navigation is made.
So, the question is: how can this be done? I've tried it with tables (CSS and HTML), but while they align over the total length, the text in the cells doesn't align on the right hand side.
The current solution is to put a custom amount of padding on the elements until they line up, but obviously this is a rubbish solution. I don't want to end up having to measure things with Javascript to lay them out, so if anyone knows of a smart way to get this done, I'd certainly appreciate it.
I do think CSS tables will get you most of the way.
You merely have to align the text of the first and last elements of each
JSfiddle Demo
CSS
* {
margin: 0;
padding: 0;
}
.menu ul {
padding: 0 3px;
display: table;
width:100%;
}
.menu-list li {
height: 45px;
list-style: none;
background-color: #f69b58;
display:table-cell;
/* add this */
text-align: center;
font-family: arial;
font-size: 14px;
margin-right: 2px;
}
.menu-list li:first-child {
text-align:left;
}
.menu-list li:last-child {
text-align:right;
}
.menu-list li a {
display: block;
padding: 13px;
color: #ffffff;
text-decoration: none;
}
.menu-list li:active {
color:black;
background-color: #3EAEE9;
}
.menu-list li:hover {
background:#3eaee9;
}
.menu-list li.current {
background-image: -webkit-linear-gradient(top, rgb(7, 80, 158), rgb(6, 101, 243));
background-color: #3EAEE9;
}
NOTE: This will NOT make the distance between each link the same, for that you will (almost certainly) require JS.
It sounds like something which concerns the right amount of divs to align the text in the center. I've made a solution in fiddle as you can see here: http://jsfiddle.net/denWG/32/
HTML:
<body>
<div class="container">
<div class="in_container">
Example Exampleson
</div>
<div class="in_container">
Producer
</div>
</div>
</body>
CSS:
.container{
width: 200px;
height: 200px;
}
.in_container{
text-align: center;
}
}
.name {
font-weight: bold;
margin: 0 auto;
}
.title {
margin: 0 auto;
font-size: 11px;
line-height: normal;
}