I've got multiple textareas. One underneath the other. There should not be any spacing between them, since I explicitly set their margin to 0.
However on chrome, there is a rather larger gap, on firefox it's small, but still there, and on IE it actually behaves as intended.
body{
background-color: #0087B3;
font-family: Helvetica, sans-serif;
}
.editor {
width: 460px;
display: inline-block;
}
.panel{
text-align: left;
margin: 10px;
padding: 12px;
background-color: rgba(255,255,255,0.1);
}
.panel .toolbar{
background-color: #007da6;
height: 40px;
}
.panel .lines{
height: 400px;
background-color: #ACE1F2;
}
.panel .lines textarea{
resize: none;
font-family: inherit;
font-size: 12pt;
padding: 8px;
box-sizing: border-box;
width: 100%;
height: auto;
overflow: hidden;
border: 0 none white;
outline: none;
margin: 0;
}
<div class="editor">
<div class="panel" id="panel">
<div class="toolbar"></div>
<div class="lines">
<textarea rows="1">There should be no space</textarea>
<textarea rows="1">between these textareas</textarea>
<textarea rows="1">however in chrome & firefox there is</textarea>
<textarea rows="1">except internet explorer</textarea>
</div>
</div>
</div>
JSFiddle to play around
Does anyone have a clue?
Thank you in advance!
You need to add display: block; to your textarea styles
.panel .lines textarea {
resize: none;
font-family: inherit;
font-size: 12pt;
padding: 8px;
box-sizing: border-box;
width: 100%;
height: auto;
overflow: hidden;
border: 0 none white;
outline: none;
margin: 0;
display: block;
}
Please check the updated fiddle here : https://jsfiddle.net/fu3ytLpt/4/
The only fix was to assign the display to match the box sizing.
display: -webkit-box;
Related
We are trying to create a chatbot application. The input where user enters the text and 'send' button are inside a div. The div width is 100%. This is working good in the laptop and on all the mobiles except Iphone14 where the send button is getting cutoff. Below is the code.
.chat-container {
background: #fff;
height: 100%;
overflow: hidden;
padding: 0;
border-right: 1px solid #d8dada;
border-left: 1px solid #d8dada;
}
.chat-container>div:last-of-type {
position: absolute;
bottom: 0;
width: 100%;
display: flex;
align-items: center;
padding-right: 10px;
}
body>div>div>div:nth-child(2)>span {
background: #dadada;
padding: 10px;
font-size: 21px;
border-radius: 50%;
}
body>div>div>div.message-data-right.macro {
margin: auto;
margin-left: 1%;
}
.chat-header {
background-color: #ffffff;
height: 3.5rem;
line-height: 3.5rem;
color: #000000;
border-bottom: 1px solid #000000;
position: relative;
}
.chat-header-content {
align-content: center;
padding-top: 10px;
padding-bottom: 10px;
}
.header-img {
height: 24px;
width: 106px;
transform: scale(0.85);
vertical-align: middle;
content: url('./../images/vz_logo.svg');
}
.gray-button {
background-color: #5b5b5b;
border: none;
color: white;
padding: 10px 24px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
font-family: Roboto-Medium;
border-radius: 4px;
}
.chat-ul {
width: 100%;
list-style-type: none;
padding: 18px 18px 3px 18px;
position: absolute;
bottom: 62px;
display: flex;
flex-direction: column;
top: 3.5rem;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #909296 #dee0e2;
background-color: #f6f6f6;
margin-bottom: 0%;
border-bottom: 1px solid #c1c1c1;
}
.entered-text {
border-width: 1px;
border-radius: 5px;
padding: 10px;
background: #f6f6f6;
width: 100%;
border-color: #c1c1c1;
}
.text {
width: 100%;
display: flex;
flex-direction: column;
}
.text>p:first-of-type {
width: 100%;
margin-top: 0;
margin-bottom: auto;
line-height: 13px;
font-size: 13px;
}
.text>p {
width: 100%;
margin-top: 0;
margin-bottom: auto;
line-height: 13px;
font-size: 13px;
}
.text>p:last-of-type {
width: 100%;
text-align: right;
margin-bottom: -2px;
margin-top: auto;
}
.text-right {
float: right;
font-family: Arial;
position: relative;
}
.send-message {
width: 100%;
border-radius: 0px;
padding: 10px;
display: flex;
}
input:focus {
outline: none;
}
button,
button:focus,
button:active {
outline: none;
}
<div class="chat-container">
<header class="chat-header">
<img class="header-img" />
<button type="button" class="icon-close" onClick="closeChatWindow()"></button>
</header>
<ul class="chat-ul"></ul>
<div>
<div class="send-message">
<div class="text text-right">
<input class="entered-text" />
</div>
</div>
<button id="send" class="gray-button" type="button" onClick="onMessageSend()"> Send </button>
</div>
</div>
Our testing team raised a bug saying that send button gets cutoff on IPhone14. I am not sure how to reproduce the issue as I don't have Iphone14. I have Android phone on which code is working fine. On Pc also, I tested on different browsers all are working fine. I used toggle device toolbar under developer tools to check how it looks like for different devices and used responsive to change width and height. I am not able to reproduce the issue. Below is the image where it got reproduced on Iphone14.
At the end of the image 'Send' grey color button is cutoff. Can any one please let me know how to resolve the issue.
You don't need an iPhone to see this. It's apparent in Chrome for me. Use the emulator in the dev tools if you like.
Remove the float (.text-right) from the layout
Take the 100% width off the input and .send-message
Move the flex class up a level to contain both the input and the button
I've also added some left margin to the button.
I've fixed a great many such situations in my career, and more often than not the solution involves removing unnecessary styling to simplify. You might work though your entire layout and do so.
.gray-button {
background-color: #5b5b5b;
border: none;
color: white;
padding: 10px 24px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
font-family: Roboto-Medium;
border-radius: 4px;
margin-left: 10px;
}
.entered-text {
border-width: 1px;
border-radius: 5px;
padding: 10px;
background: #f6f6f6;
border-color: #c1c1c1;
}
.text {
width: 100%;
display: flex;
flex-direction: column;
}
.send-message {
border-radius: 0px;
padding: 10px;
display: flex;
}
input:focus {
outline: none;
}
button,
button:focus,
button:active {
outline: none;
}
<div class="chat-container">
<div class="send-message">
<div class="text">
<input class="entered-text" />
</div>
<button id="send" class="gray-button" type="button" onClick="onMessageSend()"> Send </button>
</div>
</div>
The most straightforward way to solve this is to is use the CSS calc() function to give input.entered-text a flexible width which will always accommodate the width of the <button>:
e.g. If you give button#send a fixed width (width: 100px), then you can give input.entered-text a width that can accommodate that fixed width (width: calc(100% - 100px))
Example:
#send {
display: inline-block;
width: 100px;
margin-left: 12px;
box-sizing: border-box;
}
.entered-text {
display: inline-block;
width: calc(100% - 12px - 100px);
box-sizing: border-box;
}
Im no expert but should you put a <br> in the div
edit:
line breaks are usually unnecessary so I would say only use this temporary until you find the solution
I have this simple html with a button:
body {
background-color: White;
font-family: 'Roboto', sans-serif;
width: 800px;
margin: 0 auto;
}
div.container_body_content {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px;
margin-right: 10px;
}
div.buttondiv {
width: 100%;
height: auto;
border: 1px solid black;
display: flex;
align-items: center;
justify-content: center;
}
.button {
background-color: #93d00f;
border: none;
color: black;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
border-radius: 16px;
}
.button:hover {
background-color: Green;
}
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<div class="container_body_content">
<div class="buttondiv">
<button class="button"><span style="color:White;font-family:'Roboto';font-weight:bold;">Test Button</span></button>
</div>
</div>
When I comment out width: 800px; margin: 0 auto; for body, the button works fine and changes background-color to green on hover.
However if I have width: 800px; margin: 0 auto; set for body, the button just simply does not work, meaning background-color does not change to green on hover.
What I need is for the button to have this on hover effect even when I reduce the body width.
I can not seem to figure out what is going on, what am I doing wrong? Thank you
Strangely enough in the snippet it works, but when I open it in Safari or Google Chrome, it does not, this is how it looks like on my side:
Mystery solved, I just found a rogue DIV which I had "laid" on top of my div.buttondiv. In the snippet it works, because I attached just a MWE and left out the problematic part of the code.
This is the part of CSS that caused my problem:
#bar-graph tbody tr {
height: 296px;
padding-top: 2px;
}
Thanks everyone for your insights
I have a textarea, I have the placeholder in the middle but when I start writing more that one row, the text cuts down beacause of the padding. If I remove the padding, the placeholder is not centered.
How can I achived both things?
<div class="container">
<textarea
value={body}
onChange={e => setBody(e.target.value)}
placeholder="Escribe un mensaje"
onKeyPress={async event => {
if (event.key === "Enter") {
onSave(mutate);
}
}}
required
/>
</div>
.container {
display: flex;
flex-direction: row;
width: 100%;
height: 60px;
margin-bottom: 0px;
border-top: 1px solid grey;
}
textarea {
margin: 0px;
font-weight: normal;
font-size: 12px;
line-height: 16px;
font-family: ${props => props.theme.fonts.openSans};
border-radius: 7px;
padding: 16px;
padding-top: 20px;
box-shadow: none;
resize: none;
overflow-x: hidden;
overflow-y: scroll;
scrollbar-width: none;
box-sizing: content-box;
border: none;
border-right: 1px solid grey;
&::placeholder {
font-style: italic;
font-weight: light;
}
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #ff0000;
}
}
If you only need to center the placeholder, you don't need padding, simply add this:
textarea::placeholder {text-align: center;}
However, there are some issues with placeholder, it will work different on different browsers. You can learn more here.
Why does block with text shift to the bottom? I know how to fix this issue (need to add "overflow: hidden" to the box), but I don't understand why it shift to the bottom, text inside the box is short, margins in browser-inspector are same as margins of example without text.
Example of the problem
HTML:
<div class="with-text">
<div class="box1">
SIMPLE TEXT
</div>
<div class="box2">
</div>
</div>
<div class="without-text">
<div class="box1">
</div>
<div class="box2">
</div>
</div>
CSS:
html, body {
font-size: 10px;
margin: 0;
height: 100%;
}
.box1 {
display: inline-block;
margin: 5px;
width: 50px;
height: 50px;
background: blue;
/* Fix the problem */
/* overflow: hidden; */
color: white;
}
.box2 {
display: inline-block;
margin: 5px;
width: 50px;
height: 50px;
background: red;
}
.with-text:before {
display: block;
content: "with-text";
text-transform: uppercase;
margin: 1rem;
}
.with-text {
box-sizing: border-box;
height: 50%;
border: 1px solid;
}
.without-text:before {
display: block;
content: "without text";
text-transform: uppercase;
margin: 1rem;
}
.without-text {
box-sizing: border-box;
height: 50%;
border: 2px solid black;
}
The problem is that by default vertical alignment of inline elements – baseline,
The text inside element affects it and pushes div to the bottom.
Use vertical-align: top to solve issue.
You can try to add vertical-align:
.box1 {
display: inline-block;
margin: 5px;
width: 50px;
height: 50px;
background: blue;
/* overflow: hidden; */
color: white;
vertical-align:top;
}
I am going to make so that you can turn things up on the website like facebook, but this is how I have come into problems with my text content and my footer bar where it just gives some air in between these two.
Html here:
<div class="statusOpslag">
<asp:TextBox ID="TextBoxStatusTekst" CssClass="statusTekst" runat="server" TextMode="MultiLine"></asp:TextBox>
<div class="Statusfooter">
<asp:Button ID="ButtonSend" OnClick="ButtonSend_Click" runat="server" Text="Slå op" CssClass="statusKlikButtonOUT" />
</div>
</div>
CSS here
.statusOpslag {
background: #ffffff;
margin-bottom: 30px;
margin-top: 0;
margin: 10px;
padding: 0;
width: 95%;
}
.statusTekst {
width: 100%;
overflow: hidden;
word-wrap: break-word;
height: 120px;
max-height: 120px;
margin:0;
}
.Statusfooter {
background: #F4F4F4;
padding: 15px;
margin:0px;
}
.statusKlikButtonOUT {
background-color: #5cb85c;
border: 0;
color: green;
}
You can see it problems here
EIDT CSS
I have done as you have described in your answer and it helps nothing. - sorry
.statusOpslag {
background: #ffffff;
padding: 0;
margin: 0;
}
.statusTekst {
width: 100%;
overflow: hidden;
word-wrap: break-word;
height: 120px;
max-height: 120px;
margin:0;
}
.Statusfooter {
background: #F4F4F4;
padding: 15px;
margin:0px;
}
.statusKlikButtonOUT {
background-color: #5cb85c;
border: 0;
color: green;
}
Get rid of all the margins you set. Then, add this in css:
*{
margin: 0:
padding: 0:
}
Once it's set, you don't need to set
margin: 0;
No where again.
Also, in your statusOpslog class you set margin twice:
margin: 10px;
margin-bottom: 30px;
You should only set it once.
If you do not want that margin you got in your question you should not set margin at all for that element.