Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not-standard shaped input field

I need a text area field with an embedded button, like on this image:

 __________________________________
|Lorep ipsum lorep ipsum lorep ipsu|
|m lorep ipsum lorep ipsum lorep ip|
|sum lorep ipsum lorep ip _________|
|sum lorep ipsum lorep ip|   OK    |
|________________________|_________|

The text should flow around the button, without being hidden under it.

The only option I could imagine is custom SVG component with text and user action handlers, but that seems to be a bit overkill.

Any suggestion on simple (may be not perfect) approach for this task?

like image 442
setec Avatar asked Feb 06 '15 10:02

setec


2 Answers

I totally suck at this client-side stuff, but it seems to be possible with contenteditable.

.input {
  width: 300px;
}

.submit {
  border: 1px solid black;
  float: right;
  text-align: center;
  padding: 10px;
  cursor: pointer;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div class='input' contenteditable=true>
    <div type='button' class='submit' contenteditable=false>Save</div>
    The text should flow around the button, without being hidden under it.

The only option I could imagine is custom SVG component with text and user action handlers, but that seems to be a bit overkill.

Any suggestion on simple (may be not perfect) approach for this task?
  </div>

</body>
</html>
like image 87
Sergio Tulentsev Avatar answered Oct 25 '22 00:10

Sergio Tulentsev


It's not quite what you asked for, but maybe a different approach to take. I'm positioning the button at the bottom of a contenteditable div and only showing you it when you hover the lover section.

As i said, it's not a 'solution', more of a different approach of an issue.

.wrap {
  position: relative;
}
.text {
  height: 200px;
  width: 400px;
  background: rgba(0, 0, 0, 0.4);
  overflow:auto;
}
.bot {
  position: absolute;
  bottom: 0;
  height: 20px;
  width: 400px;
  padding-bottom: 5%;
}
button {
  position: absolute;
  height: 100%;
  width: 100px;
  right: 0;
  transition: all 0.8s;
  opacity: 0;
}
.bot:hover button {
  opacity: 1;
}
<div class="wrap">
  <div class="text" contenteditable="true">
    You can type in me! hover my lower section and you'll see the button!
  </div>
  <div class="bot">
    <button>OK</button>
  </div>
</div>

Note

This 'solution' could be tidied up, as most css styling is for 'extra bits', like overflow and transitions.

like image 38
jbutler483 Avatar answered Oct 25 '22 01:10

jbutler483