Hi everyone i want o display 3 elements in a row. I have tried the following code but it is not displaying them correctly.
<div id="mainDiv" style="background-color:#f77f00; width:90%; margin-right:5%; margin-left:5%; margin-bottom:1%; margin-top:1%;" >
<div id="left" onclick="Deletefav(this)" style="display: inline; width:20%; float:left; ">'+
'<img style="display: inline;" src="" />
</div>'+
<div id="center" onclick="" style=" width:30%; display: inline;text-align: center; margin:10%;">
<p style="display: inline;"><font color="#fff" face="verdana" size="4">testing</font></p>
</div>
<div id="right" onclick="Callfav(this)" style="display: inline; width:20%; float:right;">
<img style="display: inline;" src="" />
</div>
</div>
It is displaying like this
I want to create it like the sample image
Give display property inline-block
for inner divs:
display:inline-block;
Update:
you need to set the height for div that has jo will fix it
as other to div have images in them:
<div
id="${id}"
style="
background-color: #f77f00;
width: 90%;
margin-right: 5%;
margin-left: 5%;
margin-bottom: 1%;
margin-top: 1%;
"
>
<div
id="${_id}"
onclick="Deletefav(this)"
style="background-color: #f77f00; float: left; width: 20%; display: inline-block"
>
<img style="" src="${del_image}" /> <font color="#fff" face="verdana" size="1">delete</font>
</div>
<div
id="${_id}"
onclick=""
style="background-color: #f77f00; float: left; width: 50%; display: inline-block; height: 25px"
>
<font color="#fff" face="verdana" size="4">${name}</font>
</div>
<div
id="${_id}"
onclick="Callfav(this)"
style="background-color: #f77f00; float: left; width: 20%; display: inline-block"
>
<img style="" src="${call_image}" /><font color="#fff" face="verdana" size="1">call</font>
</div>
</div>
Add display: inline-block;
to the child divs.
Set the height of the child divs:
height: 20px /* or in %, em, etc */;
height: inherit;
which gives the height from the parent div to the children divsFrom W3Schools:
The inherit keyword specifies that a property should inherit its value from its parent element.
The inherit keyword can be used for any CSS property, and on any HTML element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With