why rating star width does not change? - html

I am trying to create a star rating button that will change based on the given rates.
here is css code:
.star-ratings-css {
unicode-bidi: bidi-override;
color: #c5c5c5;
font-size: 14px;
height: 14px;
margin: 0 auto;
position: relative;
padding:0;
margin-bottom: 3px;
text-shadow: 0.8px 0.8px 0 #a2a2a2;
}
.star-ratings-css-top {
color: #ffe111;
padding: 0;
position: absolute;
z-index: 1;
display: block;
top: 0;
left: 0;
overflow: hidden;
margin-left: 4px;
}
.star-ratings-css-bottom{
padding: 0;
display: block;
z-index: 0;
border-radius: 8px;
}
and this is the part of html code:
<div class="row" style="text-align: left;">
<div class="star-ratings-css-problem" style="width: 80px;">
<div class="row pl-5">
<div class="star-ratings-css-bottom"><span>★</span></div>
<div class="star-ratings-css-top" style="width: {% widthratio post.likes post.total_like 100 %}%;"><span>★ </span></div>
<div style="color: #ffe111"> {{ idea.like_ratio }}<span class="text-muted" style="font-size: 13px;"> ({{ post.likes|add:post.loves}})</span></div>
</div>
</div>
</div>
problem is the yellow length does not change, I mean style="width: {% widthratio post.likes post.total_like 100 %}%;" is totally behaving useless in the code!
but I expect change in the size of yellow part something like:

You could do something like this:
<div class="ratings">
<div class="empty-stars"></div>
<div class="full-stars" style="width:60%"></div>
</div>
.ratings {
p.osition: relative;
vertical-align: middle;
display: inline-block;
color: #b1b1b1;
overflow: hidden;
}
.full-stars {
position: absolute;
left: 0;
top: 0;
white-space: nowrap;
overflow: hidden;
color: #fde16d;
}
.empty-stars:before, .full-stars:before {
content:"\2605";
font-size: 14pt;
}
.full-stars:before {
-webkit-text-stroke: 1px orange;
}
https://jsfiddle.net/hed8tajo/2/

Related

Is there a way to make the text works normally?

So I'm trying to make an easy website for a server user ordering stuffs. But now I have a problem that will affect about the Navigator text.
Now it's looks like this:
As you can see in the code below, there should be a navigator text above the Back button and also the Categories button below should be shows like the back and prices button above too since they're the same code.
I tried for some other way but it's kinda out my coding range so I decide to find on Google but I don't find any helpful solve.
Is that actually can be fix?
Conclusion: problem
"Navigator" text disappear at 100% zoom view
Category buttons can't shows like buttons above (same codes as buttons above but different ID)
.title {
color: #66d4ff;
background-color: #444444;
font-size: 62px;
text-align: center;
border: solid 10px #66d4ff;
padding: 50px;
margin-left: 302px;
}
body {
background: #444444;
}
button {
color: #66d4ff;
background: #444444;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
}
a {
color: #66d4ff
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background: #4a4a4a;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-right: solid 2px #ffffff;
overflow-y: scroll;
}
.nav::-webkit-scrollbar {
display: hidden;
}
main {
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.navigator {
display: block;
margin-bottom: 50px;
color: #66d4ff;
font-size: 35px;
text-align: center;
}
.store {
padding: 0 99.5px 0 99.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.prices {
padding: 0 93.5px 0 93.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Woods {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Stones {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Brewing {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Enchanting {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Color {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Nether {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Redstone {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button class="store">Back</button>
<button class="prices">Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="Woods" onclick="document.getElementById('Woods').scrollIntoView();"><a style="text-decoration: none;">Woods</a></button>
<button class="Stones" onclick="document.getElementById('Stones').scrollIntoView();"><a style="text-decoration: none;">Stones</a></button>
<button class="ArmorsWeapon" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();"><a style="text-decoration: none;">Armors & Weapons</a></button>
<button class="Brewing" onclick="document.getElementById('Brewing').scrollIntoView();"><a style="text-decoration: none;">Brewing</a></button>
<button class="Enchanting" onclick="document.getElementById('Enchanting').scrollIntoView();"><a style="text-decoration: none;">Enchanting</a></button>
<button class="Color" onclick="document.getElementById('Color').scrollIntoView();"><a style="text-decoration: none;">Color</a></button>
<button class="Redstone" onclick="document.getElementById('Redstone').scrollIntoView();"><a style="text-decoration: none;">Redstone</a></button>
<button class="Nether" onclick="document.getElementById('Nether').scrollIntoView();"><a style="text-decoration: none;">Nether</a></button>
</div>
</div>
</nav>
I honestly can't explain all the changes made, there are too many. My attempt was to clean up your code and give you a working layout (hopefully that's what you were looking for).
In 2021 there are better layouts compared to fixed menu (with grids for example), which work better in responsive and are more clean. But it would require an in-depth study that's up to you.
body {
background-color: #444444;
}
main {
width: 100%;
padding-left: 302px;
box-sizing: border-box;
overflow:hidden;
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.title {
padding: 50px;
border: solid 10px #66d4ff;
font-size: 62px;
text-align: center;
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background-color: #4a4a4a;
border-right: solid 2px #ffffff;
overflow-y: scroll;
color: #66d4ff;
}
.navigator {
display: block;
margin-bottom: 50px;
font-size: 35px;
text-align: center;
}
button {
width:96%;
margin: 10px auto;
background: #444444;
color: #66d4ff;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
cursor:pointer;
}
<body>
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> This is a long page content...
<br/>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button>Back</button>
<button>Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="Woods items" onclick="document.getElementById('Woods').scrollIntoView();">Woods</button>
<button class="Stones items" onclick="document.getElementById('Stones').scrollIntoView();">Stones</button>
<button class="ArmorsWeapon items" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();">Armors & Weapons</button>
<button class="Brewing items" onclick="document.getElementById('Brewing').scrollIntoView();">Brewing</button>
<button class="Enchanting items" onclick="document.getElementById('Enchanting').scrollIntoView();">Enchanting</button>
<button class="Color items" onclick="document.getElementById('Color').scrollIntoView();">Color</button>
<button class="Redstone items" onclick="document.getElementById('Redstone').scrollIntoView();">Redstone</button>
<button class="Nether items" onclick="document.getElementById('Nether').scrollIntoView();">Nether</button>
</div>
</div>
</nav>
</body>
"Navigator" text disappear: This is because justify-content: center; on the nav
Buttons will not take a width of 100% even with display: block (more information), so it needs to be added. Note that since all cathegories have the same code a single class is enough.
.title {
color: #66d4ff;
background-color: #444444;
font-size: 62px;
text-align: center;
border: solid 10px #66d4ff;
padding: 50px;
margin-left: 302px;
}
body {
background: #444444;
}
button {
color: #66d4ff;
background: #444444;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
}
a {
color: #66d4ff
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background: #4a4a4a;
display: flex;
flex-direction: column;
align-items: center;
/* justify-content: center; */
border-right: solid 2px #ffffff;
overflow-y: scroll;
}
.nav::-webkit-scrollbar {
display: hidden;
}
main {
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.navigator {
display: block;
margin-bottom: 50px;
color: #66d4ff;
font-size: 35px;
text-align: center;
}
.store {
padding: 0 99.5px 0 99.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.prices {
padding: 0 93.5px 0 93.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.category {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
width: 100%;
}
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button class="store">Back</button>
<button class="prices">Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="category Woods" onclick="document.getElementById('Woods').scrollIntoView();"><a style="text-decoration: none;">Woods</a></button>
<button class="category Stones" onclick="document.getElementById('Stones').scrollIntoView();"><a style="text-decoration: none;">Stones</a></button>
<button class="category ArmorsWeapon" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();"><a style="text-decoration: none;">Armors & Weapons</a></button>
<button class="category Brewing" onclick="document.getElementById('Brewing').scrollIntoView();"><a style="text-decoration: none;">Brewing</a></button>
<button class="category Enchanting" onclick="document.getElementById('Enchanting').scrollIntoView();"><a style="text-decoration: none;">Enchanting</a></button>
<button class="category Color" onclick="document.getElementById('Color').scrollIntoView();"><a style="text-decoration: none;">Color</a></button>
<button class="category Redstone" onclick="document.getElementById('Redstone').scrollIntoView();"><a style="text-decoration: none;">Redstone</a></button>
<button class="category Nether" onclick="document.getElementById('Nether').scrollIntoView();"><a style="text-decoration: none;">Nether</a></button>
</div>
</div>
</nav>

Website looks different between Chrome and Safari

i am programming an App with Angular. And the problem is, that my button is looking different in Safari on my iPhone then on my Simulated iPhone in Chrome.
in Chrome it looks like this:
And on my iPhone it looks like this:
I know that it could be a problem because i have not implemented anything webkit related, but i couldnt find something with webkit that could help me with this.
The Code is the Following:
#colorPicker button {
border: none;
border-radius: 30px;
width: 100%;
height: 86%;
position: relative;
top: -6%;
overflow: hidden;
}
#colorPicker i {
color: white;
}
#colorPicker #second {
background-color: rgb(48, 209, 88);
}
#colorPicker #third {
background-color: rgb(12, 50, 102);
}
#colorPicker #fourth {
background-color: rgb(0, 0, 0);
}
#content {
overflow: hidden;
}
.resetSettings {
border: none;
padding: none;
margin: none;
border-radius: 25px;
color: white;
}
#activeButton {
color: white;
background-color: rgb(88, 86, 214);
width: 100%;
height: 120%;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border: none;
padding: none;
margin: none;
}
#settingsDatenschutz {
width: 80%;
border: none;
background-color: transparent;
padding: none;
margin: none;
margin-right: 10%;
margin-left: 10%;
border-radius: 25px;
font-family: Arial, Helvetica, sans-serif;
}
#settingsDatenschutz p {
font-size: 18pt !important;
font-family: Arial, Helvetica, sans-serif !important;
}
#settingsDatenschutz i {
font-size: 18pt !important;
}
#datenschutz {
margin: none;
border: none;
padding: none;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
top: 0;
bottom: 0;
right: 0;
left: 0;
width: 100%;
height: 100%;
position: fixed;
z-index: 102;
background-color: rgb(44, 44, 46);
overflow-y: scroll;
}
#datenschutz button {
width: 100%;
bottom: 0;
position: fixed;
font-size: 20pt;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<style>
#content {
background-color: white;
color: black;
border: none;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
margin: 5%;
margin-top: 2%;
width: 90%;
position: relative;
top: 12%;
left: 0;
right: 0;
overflow: scroll;
padding: 15px;
font-size: 20pt;
}
#content i {
font-size: 28pt;
padding-top: 5px;
}
#content p {
display: inline;
}
#view {
z-index: 2;
position: relative;
top: 0;
margin: none;
width: 100%;
height: 100%;
}
#colorPicker {
width: 90%;
height: 90%;
margin: 5%;
margin-top: 20%;
}
/* #colorPicker button {
border: none;
border-radius: 30px;
width: 100%;
position: relative;
top: -6%;
}
#colorPicker i {
color: white;
}
#colorPicker #default {
background-color: rgb(10, 132, 255);
}
#colorPicker #second {
background-color: rgb(48, 209, 88);
}
#colorPicker #third {
background-color: rgb(12, 50, 102);
}
#colorPicker #fourth {
background-color: rgb(0, 0, 0);
} */
</style>
<div id="view">
<div id="content">
<br>
<div id="colorPickerButtonView">
<div class="row">
<div id="firstMain" class="col-6">
<div class="activeColorFromColorPicker" id="colorPicker">
<button class="primaryColorDefault" alt="Hellblauer Hintergrund, weiße Schrift" onclick="colorPicker(0)" id="default">
<br>
<i class="fab fa-accessible-icon"></i>
<br>
<div id="activeButton">
<p>Active!</p>
</div>
</button>
</div>
</div>
<div id="secondMain" class="col-6">
<div id="colorPicker">
<button alt="Helglgrüner Hintergrund, weiße Schrift" onclick="colorPicker(1)" id="second">
<br>
<i class="fab fa-accessible-icon"></i>
<br>
<div id="activeButton">
<p>Active!</p>
</div>
</button>
</div>
</div>
<div id="thirdMain" class="col-6">
<div id="colorPicker">
<button alt="Dunkelblauer Hintergrund, weiße Schrift" onclick="colorPicker(2)" id="third">
<br>
<i class="fab fa-accessible-icon"></i>
<br>
<div id="activeButton">
<p>Active!</p>
</div>
</button>
</div>
</div>
<div id="fourthMain" class="col-6">
<div id="colorPicker">
<button alt="Schwarzer Hintergrund, weiße Schrift" onclick="colorPicker(3)" id="fourth">
<br>
<i class="fab fa-accessible-icon"></i>
<br>
<div id="activeButton">
<p>Active!</p>
</div>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<router-outlet></router-outlet>
The given code has several errors in the HTML such as multiple instances of the same id.
The error that is most likely to be confusing browsers as they won't necessarily know how you want the code parsed is having a div (and also a p) element within a button element. This is not allowed in the spec. See for example div not allowed as child element of button
Run your code through the W3C validator to get the full details.
Then the best thing to do next is probably to change the button elements for div elements with class="button", change the CSS which refers to button to .button
And check and correct any other validation errors.
Then if the problem is not cured we are at least on solid ground for having a further look - particularly at the implementations of class="row" when an inner div has a height larger than the container such as you have in this example

How to Place a vertical line between each image?

I would like to place a vertical line between each image, I have tried several things but without success.
Here is an idea of the final result. There is a vertical gray line between the two images.
How to create the vertical line?
.background-contact{
background-color: white;
width: 100%;
height: 190px;
position: absolute;
}
.logo5{
padding-top: -70px;
padding-left: 38px;
}
.title-contact-1{
font-family: 'Questrial', sans-serif;
font-size: 22px;
margin-top: -32px;
padding-left: 20px;
position: relative;
text-transform: uppercase;
font-weight: bold;
}
.text-contact-1{
font-family: 'Questrial', sans-serif;
font-size: 14px;
top: 22%;
left: -12%;
position: relative;
transform: translateX(-50%);
}
.logo6{
padding-top: 35px;
left: -80%;
}
<div class="background-contact">
<img class="logo5" src="https://i.ibb.co/0YyTszS/title-icon1.png" >
<span class="title-contact-1">Telephone</span>
<span class="text-contact-1">Just For VIP Member</span>
<img class="logo6" src="https://i.ibb.co/026Fs1B/title-icon2.png" >
<span class="title-contact-1">E-mail Us</span>
<span class="text-contact-1">admin#superbtc.biz</span>
</div>
I didn't do the pixel perfect but something like this:
.background-contact{
background-color: white;
width: 100%;
position: absolute;
display: flex;
}
.background-contact__block {
padding-bottom: 20px;
}
.background-contact__block + .background-contact__block {
margin-left: 50px;
padding-left: 20px;
border-left: 1px solid #ccc;
}
.title-contact-1{
font-family: 'Questrial', sans-serif;
font-size: 22px;
vertical-align: middle;
text-transform: uppercase;
font-weight: bold;
display: inline-block;
}
.text-contact-1{
font-family: 'Questrial', sans-serif;
font-size: 14px;
display: block;
}
.logo{
display: inline-block;
vertical-align: middle;
}
.background-contact__name {
padding-bottom: 30px;
}
<div class="background-contact">
<div class="background-contact__block">
<div class="background-contact__name">
<img class="logo" src="https://i.ibb.co/0YyTszS/title-icon1.png" >
<span class="title-contact-1">Telephone</span>
</div>
<span class="text-contact-1">Just For VIP Member</span>
</div>
<div class="background-contact__block">
<div class="background-contact__name">
<img class="logo" src="https://i.ibb.co/026Fs1B/title-icon2.png" >
<span class="title-contact-1">E-mail Us</span>
</div>
<span class="text-contact-1">admin#superbtc.biz</span>
</div>
</div>
to create a border you can use
border: (width) (style) (color);
This will make a border all around the element, to select one side you can use
border-left:
border-right:
border-top:
border-bottom:
But here your css is very strange, I recommend you to use the less as possible absolute positioning.
Here a better way do write that :
.contact-item {
width: 200px;
display: inline-block;
}
.contact-item img,
.contact-item h1 {
display: inline-block;
}
.border-left {
border-left: 2px solid #ddd;
padding-left: 1rem;
}
<div id="background-contact">
<div class="contact-item">
<img src="https://i.ibb.co/0YyTszS/title-icon1.png">
<h1>Telephone</h1>
<p>text<p>
</div>
<div class="contact-item border-left">
<img src="https://i.ibb.co/026Fs1B/title-icon2.png">
<h1>Email Us</h1>
<p>text</p>
</div>
</div>
you can also use :
element::last-child {
border-left: .. .. ..;
}

children not staying inside parent divs

Fiddle: https://jsfiddle.net/uatzust3/
Here is the fiddle for my problem, you'll observe that the children are not staying inside the parent div card and also I want the divs to take full width of parent which they are not taking.
Also, where should I be learning best practices? I am new to the community. Thanks in advance.
The left div(black_container) is short of content but should arrange the height according to the width of the right div(content_container) all the while staying inside the card div.
.card {
box-shadow: 0 25px 45px rgba(0, 0, 0, 0.30), 0 15px 15px rgba(0, 0, 0, 0.22);
max-width: 800px;
margin: auto;
position: relative;
}
.black_container {
height: inherit;
background: #333;
display: inline-block;
vertical-align: top;
padding: 3%;
font-family: 'Nunito', sans-serif;
}
.content_container {
display: inline-block;
padding: 3%;
/* position: absolute;
top:0;
bottom: 0; */
}
.small_bar {
padding: 3px;
width: 30px;
margin: 0 auto;
background: #e4e4e4;
margin-top: 35px;
}
.name {
color: #fff;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 5px;
margin: 30px auto 5px auto;
text-align: center;
font-weight: 800;
}
.designation {
font-size: 10px;
margin: 0 auto;
}
.qrcode_container {
float: right;
}
.qr_container {
overflow: auto;
width: 100%;
}
.qr_text {
display: inline-block;
list-style-type: none;
}
.qr_text>li {
font-size: 18px;
font-weight: 600;
letter-spacing: 2.5px;
color: #9a9a9a;
}
.bars {
display: inline-block;
position: relative;
top: 10px;
}
.bars .small_bar {
width: 15px;
background: #777;
}
.bar {
position: absolute;
top: -80px;
}
.qr_code {
display: inline-block;
height: inherit;
border: 1px solid #e4e4e4;
padding: 5px;
}
.button {
width: 150px;
letter-spacing: 1;
text-transform: uppercase;
font-weight: 600;
color: #fff;
text-align: center;
background: #333;
padding: 5px 10px;
}
<div class="card">
<div class="black_container">
<div class="circular">
</div>
<p class="small_bar"></p>
<p class="name">wow</p>
<p class="name designation">Front-End Designer</p>
</div>
<div class="content_container">
<!-- qr code container ends -->
<div class="qr_container">
<div class="qrcode_container">
<ul class="qr_text">
<li>LOREM</li>
<li>IPSUM</li>
<li>DPOLER</li>
</ul>
<div class="bars">
<div class="small_bar bar"></div>
<div class="small_bar"></div>
</div>
<div class="qr_code"></div>
</div>
</div>
<!-- qr code container ends -->
<div class="card_content">
<p>Hello!</p>
<p>My name is lorem</p>
<p>I am a web designer</p>
<p>Im stuck</span>
</p>
<div class="button">button</div>
</div>
<div class="card_footer"></div>
</div>
</div>
A parent cannot take the height of a direct child if the child is absolute because the absolute elements are removed from the document flow(like floats), so in this case "card" doesn't even know "content_container" even exists .
https://jsfiddle.net/OmarIsComing/eq4L86g9/1/
update:
solution with flexbox: https://jsfiddle.net/OmarIsComing/eq4L86g9/2/
solution without flexbox: https://jsfiddle.net/OmarIsComing/eq4L86g9/3/
If flexbox is an option, this is easy :
Add display: flex to your card
Add flex: 1 to the content-container
See demo below:
.card {
box-shadow: 0 25px 45px rgba(0, 0, 0, 0.30), 0 15px 15px rgba(0, 0, 0, 0.22);
max-width: 800px;
margin: auto;
position: relative;
display: flex;
}
.black_container {
height: inherit;
background: #333;
display: inline-block;
vertical-align: top;
padding: 3%;
font-family: 'Nunito', sans-serif;
}
.content_container {
display: inline-block;
padding: 3%;
/* position: absolute;
top:0;
bottom: 0; */
flex: 1;
}
.small_bar {
padding: 3px;
width: 30px;
margin: 0 auto;
background: #e4e4e4;
margin-top: 35px;
}
.name {
color: #fff;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 5px;
margin: 30px auto 5px auto;
text-align: center;
font-weight: 800;
}
.designation {
font-size: 10px;
margin: 0 auto;
}
.qrcode_container {
float: right;
}
.qr_container {
overflow: auto;
width: 100%;
}
.qr_text {
display: inline-block;
list-style-type: none;
}
.qr_text>li {
font-size: 18px;
font-weight: 600;
letter-spacing: 2.5px;
color: #9a9a9a;
}
.bars {
display: inline-block;
position: relative;
top: 10px;
}
.bars .small_bar {
width: 15px;
background: #777;
}
.bar {
position: absolute;
top: -80px;
}
.qr_code {
display: inline-block;
height: inherit;
border: 1px solid #e4e4e4;
padding: 5px;
}
.button {
width: 150px;
letter-spacing: 1;
text-transform: uppercase;
font-weight: 600;
color: #fff;
text-align: center;
background: #333;
padding: 5px 10px;
}
<div class="card">
<div class="black_container">
<div class="circular">
</div>
<p class="small_bar"></p>
<p class="name">wow</p>
<p class="name designation">Front-End Designer</p>
</div>
<div class="content_container">
<!-- qr code container ends -->
<div class="qr_container">
<div class="qrcode_container">
<ul class="qr_text">
<li>LOREM</li>
<li>IPSUM</li>
<li>DPOLER</li>
</ul>
<div class="bars">
<div class="small_bar bar"></div>
<div class="small_bar"></div>
</div>
<div class="qr_code"></div>
</div>
</div>
<!-- qr code container ends -->
<div class="card_content">
<p>Hello!</p>
<p>My name is lorem</p>
<p>I am a web designer</p>
<p>Im stuck</span>
</p>
<div class="button">button</div>
</div>
<div class="card_footer"></div>
</div>
</div>
Use the class card-body, this will keep the contents inside of the card.
<div class="card border-success">
<div class="card-header border-success">
<h3 class="card-title">Card Title</h3>
</div>
<div class="card-body border-success">
<dl>
<dt>
Stuff
</dt>
<dd>
Stuff Details
</dd>
</dl>
</div>
</div>
replace the .content_container css with:
.content_container {
display: inline-block;
padding: 3%;
vertical-align: top;
}
I think the CSS attribute position: absolute; is causing this issue. In short, absolute position removes the element from the flow of other elements; therefore, its height is simply ignored, and never counted in your .card container.

Why is my div moving to right whenever I add "overflow-y: scroll"?

Why is my div moving to right whenever I specify overflow-y: scroll on the .messages element?
Even when I use margin-left: -10px;, it doesn't move to the left!
#import url(http://fonts.googleapis.com/css?family=Roboto:300,400,900);
#import url(http://weloveiconfonts.com/api/?family=entypo);
[class*="entypo-"]:before {
font-family: 'entypo', sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
}
body {
background: #BDC1C6;
font-family: 'Roboto';
}
p {
font-weight: 300;
}
.chat {
width: 300px;
background: #fff;
margin: 0 auto;
}
header {
background: #35323C;
height: 50px;
padding: 5px 10px;
}
.menu-icon {
background: #2F2E33;
padding: 5px 10px;
float: left;
font-size: 3em;
line-height: 0.5em;
color: #fff;
border-radius: 3px;
}
.menu-icon:hover {
background: #39caad;
cursor: pointer;
}
h1 {
float: right;
color: #fff;
margin: 5px;
font-weight: 300;
font-size: 1.3em;
}
.menulist {
background: #39caad;
color: #fff;
text-align: center;
padding: 10px;
}
.menulist:hover {
cursor: pointer;
background: rgb(255, 0, 0);
text-align: center;
padding: 20px;
}
.openchat {
background: #39caad;
color: #fff;
text-align: center;
padding: 5px;
}
.new {
background: rgb(57, 202, 173);
color: #fff;
text-align: center;
padding: 20px;
}
.new:hover {
cursor: pointer;
background: rgba(57, 202, 173, 0.9);
}
.messages {
padding: 10px;
overflow-y: scroll;
height: 300px;
}
.message {
float: left;
width: 100%;
margin: 10px 0;
border-bottom: 1px solid #ccc;
}
.message p {
font-size: 0.8em;
width: 90%;
margin: 5px 0;
}
.message:hover {
background: #39caad;
cursor: pointer;
}
.messageSender {
text-align: right;
float: right;
width: 100%;
margin: 10px 0;
border-bottom: 1px solid #ccc;
}
.messageSender p {
font-size: 0.8em;
width: 90%;
margin: 5px 0;
}
.messageReceiver {
float: left;
width: 100%;
margin: 10px 0;
border-bottom: 1px solid #ccc;
}
.messageReceiver p {
font-size: 0.8em;
width: 90%;
margin: 5px 0;
}
img {
border-radius: 100%;
float: left;
margin: 0 10px 15px 0;
}
img.sender {
border-radius: 100%;
float: right !important;
margin: 0 10px 15px 0;
width: 35px;
height: 35px;
}
img.receiver {
border-radius: 100%;
float: left;
margin: 0 10px 15px 0;
width: 35px;
height: 35px;
}
p.time {
color: rgba(0, 0, 0, 0.5);
font-weight: 400;
}
p.chattime {
color: rgba(0, 0, 0, 0.5);
font-weight: 400;
font-size: 10px;
}
h2 {
font-size: 1em;
font-weight: 400;
}
h2:after {
content: '';
display: inline-block;
height: 10px;
width: 10px;
background: #39caad;
border-radius: 100%;
margin-left: 5px;
}
h2.send:before {
content: '';
display: inline-block;
height: 10px;
width: 10px;
background: #39caad;
border-radius: 100%;
margin-left: 5px;
}
h2.send:after {
content: '';
height: 0px;
width: 0px;
border-radius: 00%;
margin-right: 5px;
}
footer {
width: 100%;
background: #fff;
padding: 10px;
text-align: center;
font-size: 0.8em;
}
footer p:before,
footer p:after {
content: ' - ';
}
<div class="chat">
<header>
<div class="menu-icon" id="menubutton"><span class="entypo-menu"></span>
</div>
<h1>Chats</h1>
</header>
<?php include( "menu.php"); ?>
<div class="openchat" id="openchat">
<img style="width:35px; height: 35px;" src="http://dtechnomist.com/clients/chat/assets/users/2.jpg" />
<h2>XYZ</h2>
<p class="time">Online</p>
</div>
<section class="messages" id="chatBox">
<div class="messageReceiver">
<img class="receiver" src="assets/users/1.jpg">
<h2 class="receive">Admin 1</h2>
<p class="chattime">12:00:00 AM, 3rd Jan16</p>
<p>There ?</p>
</div>
<br>
<br>
<div class="messageSender">
<img class="sender" src="assets/users/2.jpg">
<h2 class="send"> You</h2>
<p class="chattime">12:00:00 AM, 4th Jan16</p>
<p>Yes</p>
</div>
<br>
<br>
<div class="messageReceiver">
<img class="receiver" src="http://dtechnomist.com/clients/chat/assets/users/1.jpg">
<h2 class="receive">Admin 1</h2>
<p class="chattime">08:59:33 PM, 4th Jan16</p>
<p></p>
</div>
<div class="messageReceiver">
<img class="receiver" src="assets/users/1.jpg">
<h2 class="receive">Admin 1</h2>
<p class="chattime">09:05:55 PM, 4th Jan16</p>
<p>hi</p>
</div>
<br>
<br>
<div class="messageReceiver">
<img class="receiver" src="http://dtechnomist.com/clients/chat/assets/users/1.jpg">
<h2 class="receive">Admin 1</h2>
<p class="chattime">09:06:02 PM, 4th Jan16</p>
<p>ok</p>
</div>
<br>
<br>
<div class="messageSender">
<img class="sender" src="http://dtechnomist.com/clients/chat/assets/users/2.jpg">
<h2 class="send"> You</h2>
<p class="chattime">09:06:58 PM, 4th Jan16</p>
<p>hello</p>
</div>
<br>
<br>
<div class="messageSender">
<img class="sender" src="http://dtechnomist.com/clients/chat/assets/users/2.jpg">
<h2 class="send"> You</h2>
<p class="chattime">09:07:08 PM, 4th Jan16</p>
<p>hi</p>
</div>
<br>
<br>
<div class="messageSender">
<img class="sender" src="http://dtechnomist.com/clients/chat/assets/users/2.jpg">
<h2 class="send"> You</h2>
<p class="chattime">09:07:31 PM, 4th Jan16</p>
<p>asd</p>
</div>
</section>
<section class="write">
<textarea type="text" name="msg" id="msg" style="width:85%; height: 30px; margin: 0px 0px 0px 2%; resize: none" placeholder="Type your message here..."></textarea>
<button name="send" id="sendMsg" style="width: 9%;"><span class="entypo-plus"></span>Send</button>
</section>
<footer>
<p>Designed by Kashan Shah
</p>
</footer>
</div>
You're seeing this behavior due to collapsing margins.
When you add overflow-y: scroll to the element, a new block formatting context is established, which means that the .openchat element's vertical margin no longer collapses with the .messages element. Since the margins no longer collapse, the element is shifted to the right.
Margins of elements that establish new block formatting contexts (such as floats and elements with overflow other than visible) do not collapse with their in-flow children.
To resolve this issue, you could either add overflow: hidden to the .openchat element in order hide the overflowing margin (which essentially prevents the margin from adjoining):
Updated Example
.openchat {
background: #39caad;
color: #fff;
text-align: center;
padding: 5px;
overflow: hidden;
}
Alternatively, you could also just remove the margin-bottom from the child img element:
Updated Example
.openchat img {
margin-bottom: 0;
}