Home > OS >  Can anyone help styling following html structure to the image shown below? Is it possible to do it o
Can anyone help styling following html structure to the image shown below? Is it possible to do it o

Time:11-22

Is it possible to style the following HTML structure to the image shown below with CSS only?

<div class="xyz-dialog">
 <div class="title"><span> Tip Title</span></div>
 <div class="body"> <span>Description</span></div>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

Design Required design

CodePudding user response:

You can do it so if we can add a container div in the HTML:

.container{
  background: gray;
  padding: 16px 10px;
  width:max-content;
}
.xyz-dialog {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  position: relative;
  width: 300px;
}

.xyz-dialog::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid white;
  position: absolute;
  top: 100%;
}
.body {
  margin-top:8px;
  color: gray;
  font-size: 15px
}
<div class= "container">
  <div class="xyz-dialog">
  <div class="title"><span> Tip Title</span></div>
  <div class="body"> <span>Description</span></div>
</div>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

You can do it so if we cannot touch the HTML structure :

.xyz-dialog {
  padding: 1rem;
  border-radius: 8px;
  position: relative;
  width: 300px;
}

.xyz-dialog::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid white;
  position: absolute;
  top: calc(100% -1rem);
  left: 2rem;
}
.xyz-dialog::before {
  content: "";
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: gray;
  z-index: -1;
}
.title {
  padding: 1rem;
  background: white;
  border-radius: 10px 10px 0 0;
  margin: 0 0 -5px 0;
}

.body {
  color: gray;
  font-size: 15px;
  background: white;
  margin: 0;
  padding: 1rem;
  border-radius: 0 0 10px 10px;
}
<div class="xyz-dialog">
  <div class="title"><span> Tip Title</span></div>
  <div class="body"> <span>Description</span></div>
</div>
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

You can use after and border.

.xyz-dialog::after{
    content: "";
    border-top: 12px solid #f1f1f1;
    border-right: 8px solid transparent;
    border-left: 8px solid transparent;
    position: absolute;
    bottom: -12px;
    left: 4%;  
}

.xyz-dialog{
    width: 50%;
    background: #f1f1f1;
    border-radius: 0.3em;
    padding: 5px 30px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
    flex-direction: column;
}
<div class="xyz-dialog">
 <div class="title"><span> Tip Title</span></div>
 <div class="body"> <span>Description</span></div>
</div>
<iframe name="sif4" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Little late. Two Boxes. For the small noise you use the css pseudo class after.

body {
  background-color: #999;
}
.wrapper {
  padding:20px;  
}
h3 {
  margin:0;
  color: #000;
}
.bubble {
    position: relative;
    background: white;
    color: #999;
    font-family: Arial;
    font-size: 16px;    
    text-align: left;
    width: 250px;
    height: 120px;
    border-radius: 10px;
    padding: 0px;
}
.bubble:after {
    content: '';
    position: absolute;
    display: block;
    width: 0;
    z-index: 1;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent #fff transparent transparent;
    bottom: -16px;
    left: 17%;
    margin-left: -10px;
}
<div class="bubble">
  <div class="wrapper">
    <h3>title</h3>
    <div>content</div>
  </div>
</div>
<iframe name="sif5" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related