I need to align text and buttons at the right and middle of a text area; these three elements are in a cell of a table.
The best I’ve gotten is with this HTML snippet:
.fg_Erase {
color: #880;
margin-left: -12px;
padding-right: 4px;
border: none;
background: rgba(0, 0, 0, 0)
}
.fg_Erase:hover,
img:hover {
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<table>
<tr>
<td style='display: flex;'>
<textarea cols="50" rows="5" id="bigT" name="bigT"></textarea>
<button class="fg_Erase" onclick="$('bigT').value = ''">✘</button>
<button type="button" name="info" id="info" class="fg_GButton">
<img src="images/info.png" class="fg_alignImg"></button>
</td>
</tr>
</table>
However I had to insert the two objects into buttons with the unpleasant effect that the pointer cursor extends beyond the objects, i.e. it covers the height of the text area.
So two requests:
- how to obtain alignment without using buttons, but only span and img tags;
- how do you have the pointer cursor on the object only (text or image)?
2
Answers
I changed the first button to a span and removed the button around the img, as that sounded like your intent.
I set the to grid, set columns and centering.
Apart from flex box and grid layout. You can achieve the same with positions relative and absolute.