why same css not used for both circles - html

I have a very basic question, which will help me understanding the CSS entirely,I believe. Below is the CSS and HTML for my code.
.vl {
border-left: 6px solid yellow;
height: 100px;
margin-bottom: none;
}
.circle {
border: 2px solid #666666;
border-radius: 100%;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
filter: alpha(opacity=60);
opacity: 0.6;
-webkit-box-shadow: 0 0 1px 0px rgb( 255, 255, 255);
box-shadow: 0 0 1px 0px rgb( 255, 255, 255);
width: 17px;
height: 17px;
z-index: 86;
margin-left: -7px;
-webkit-transition: background-color .5s ease-in-out;
-moz-transition: background-color .5s ease-in-out;
-o-transition: background-color .5s ease-in-out;
-ms-transition: background-color .5s ease-in-out;
transition: background-color .5s ease-in-out;
}
<div class="vl"></div>
<div class="circle" />
<div class="vl" style="margin-top: 18px; margin-left: 4.8px;"></div>
Now, the results appear like this:
After that When I add another circle div <div class="circle"/>. Results looks like this:
I have two queries based upon my results:
Why my second circle didnt appear in the same margins to the left as the first one? I am using same css.
How do we create elements like circles or lines, that whenever we use them they perfectly aligns to the elements next to them automatically. I have seen this but never gets it.
Please refer to image below:
,
as soon as I'm adding more divs of same classes, it looses its colors, the colors are getting lighter.

This is happening to you because you have used an invalid HTML tag. <div /> is not a valid tag whereas you should have used <div></div>.
Follow this MDN web docs link to find the actual use cases:
Tag omission: None, both the starting and ending tag are mandatory.
When you correct this problem, all the classes you will declare, and how many times you call them, that doesn't matter, all of them will have same styling, like- in your case, same margin, no color fading, etc. Try it out:
.vl {
border-left: 6px solid yellow;
height: 100px;
margin-bottom: none;
}
.circle {
border: 2px solid #666666;
border-radius: 100%;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
filter: alpha(opacity=60);
opacity: 0.6;
-webkit-box-shadow: 0 0 1px 0px rgb( 255, 255, 255);
box-shadow: 0 0 1px 0px rgb( 255, 255, 255);
width: 17px;
height: 17px;
z-index: 86;
margin-left: -7px;
}
<h2>Vertical Line</h2>
<div class="vl"></div>
<div class="circle"></div>
<div class="vl"></div>
<div class="circle"></div>
<div class="vl"></div>
<div class="circle"></div>
<div class="vl"></div>
<div class="circle"></div>

Related

Child div does not fill the parent div when using rounded corners

Per the title, you can see a demo of the issue here.
Here is the HTML code:
<div id="outer">
<div id="inner">
</div>
</div>
Here is the CSS code:
#inner{
height: 100%;
width: 100%;
border-radius: 20px;
text-shadow: 5px 5px 5px #000000;
background-color: white;
opacity: 0;
-webkit-transition: opacity .5s linear;
-moz-transition: opacity .5s linear;
transition: opacity .5s linear;
}
#inner:hover{
opacity: 1;
}
#outer{
border: 6px solid #dcc5c5;
border-radius: 20px;
text-shadow: 5px 5px 5px #000000;
position: relative;
display: inline-block;
transition: all 0.5s ease-in-out;
background-color: red;
height: 200px;
width: 200px;
}
I've tried various suggestions here and here with no solution.
you are using margin-top:20px;
in this element
#inner {
height: 100px;
background-color: #42749F;
width: 200px;
/* -1px here for to compansate for the outer border of the container */
-moz-border-radius: 0 0 9px 9px;
}
remove margin and it will fill inside parent element
Working fiddle
The problem in that is that the child takes priority, if the parent div says:
text-font: Sans-Serif
but the child says:
text-font: Arial
the elements in the child sector take priority. In other words, the parent is the "Default". The same happens to "rounded corners" and "margin-top". The "margin-top" takes priority.
Just make sure that those two are correct.
I guess the border you've set on the inside division is creating problems here. Removing the border makes the child element fully fill the parent.
Is this what you were looking for? You may elaborate more if you want, in comments.
.box {
position: relative;
overflow: hidden;
border-radius: 20px;
transition: all 0.5s ease-in-out;
background-color: red;
height: 200px;
width: 200px;
}
.scratcher{
height: 100%;
width: 100%;
background-color: white;
opacity: 0;
transition: opacity .5s linear;
}
.scratcher:hover{
opacity: 1;
}
<div class="box">
<div class="scratcher">Scratcher</div>
</div>
I noticed that if you offset the difference (6px) in border-width of the containing element (.box_1 / #outer), with the border-radius of the nested element (#scratcher / #inner), you will fill up the corner gaps.
Deduct 6px from the border-radius value of the nested element (#scratcher / #inner).
#inner {
height: 100%;
width: 100%;
border-radius: 13px;
text-shadow: 5px 5px 5px #000000;
background-color: white;
opacity: 0;
-webkit-transition: opacity .5s linear;
-moz-transition: opacity .5s linear;
transition: opacity .5s linear;
}
#inner:hover {
opacity: 1;
}
#outer {
border: 6px solid #dcc5c5;
border-radius: 20px;
text-shadow: 5px 5px 5px #000000;
position: relative;
display: inline-block;
transition: all 0.5s ease-in-out;
background-color: red;
height: 200px;
width: 200px;
}
<div id="outer">
<div id="inner">
</div>
</div>

WhatsApp Share button for blogger

I've a WhatsApp share button but I'm facing some issue with it. sharing function works well but the problem is that when the page loads(or while leaving the page), the background color of the button is displayed on the entire page for a short period of time which looks ugly. Can somebody help me to fix it? What should I change in this code so that the original theme color will be displayed while page loading instead of this WhatsApp button's color? Thanks in advance.
<style>
body{background-color:#49C34F}
.mct_whatsapp_btn {
background: #11A518;
color: white;
font-size: 16px;
padding: 6px 9px 6px 28px;
border-radius: 2px;
position: relative;
transition: ease-in all 0.3s;
moz-transition: ease-in all 0.3s;
-o-transition:ease-in all 0.3s;
-webkit-transition: ease-in all 0.3s;
text-decoration: none;
box-shadow: inset 3px 1px 1px rgba(17, 165, 24, 0.25);
border: 1px solid #028408;
}
.mct_whatsapp_btn:before {
content: '';
background: url(BACKGROUND IMAGE URL);
position:absolute;
top: 6px;
left: 7px;
width:16px;
transition: ease-in all 0.3s;
moz-transition: ease-in all 0.3s;
-o-transition:ease-in all 0.3s;
-webkit-transition: ease-in all 0.3s;
height:16px;
}
.mct_whatsapp_btn:hover {
background: #028408;
text-decoration: none;
color:white;
border: 1px solid #11A518;
box-shadow: inset 3px 1px 1px rgba(2, 132, 8, 0.25);
}
.mct_whatsapp_btn:hover:before {
transform: rotate(360deg);
}
</style>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 well">
<a class="mct_whatsapp_btn" data-link="" data-text="" href="whatsapp://send?text=">Share</a>
</div>
Remove the first block of code body{background-color:#49C34F}

Transition instant set border, show slowly

Currently I have images as checkboxes which I can click then a yellow border comes up with transition.
Obviously it changes the margin stuff and everything when the border comes up so i set a default margin of 3px wich goes away when the border is comming(the border is 3px too)
but since i used transition onto the border it grows up and while the border is growing all the images are shuttering and shaking :D
So now i would have to make the border be there instantly on 3px as soon as i klick it but it shouldnt instantly show as 3px...
i have no idea how to do that here's my current css
theres a little part of the css missing but stack overflow doesn't let me upload it because it doesn't accept it as code....
img{
width: 100%;
max-width: 380px;
border: 3px solid rgba(255.0.0.0);
background-color:black;
height: 100%;
max-height: 250px;
margin: 3px;
border-radius:15px;
transition:opacity 2s ease, border 1s ease;
opacity: 0.5;
}
<img src="http://placehold.it/380x250" />
Why not just have the border there as transparent and the just transition the ``border-color`?
img {
width: 100%;
max-width: 380px;
border: 3px solid transparent;
height: 100%;
max-height: 250px;
margin: 3px;
border-radius: 15px;
transition: opacity 2s ease, border-color 1s ease;
opacity: 0.5;
}
img:hover {
border-color: red;
}
<img src="http://placehold.it/200x200" />
If you want not to break layout while adding border, you may consider using
box-shadow
instead of border property, and transitioning this.
$('.box').on('click', function() {
$(this).addClass('box--checked');
});
.box {
width: 120px;
height: 120px;
transition: box-shadow .3s linear;
margin-bottom: 12px;
background-color: #DDD;
box-shadow: 0px 0px 0px 0px darkorange;
}
.box--checked {
box-shadow: 0px 0px 0px 6px darkorange;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<div class="box box--one">A</div>
<div class="box box--two">B</div>
<div class="box box--three">C</div>

CSS button effects

Demo
.common_button:active
{
box-shadow: 0px 3px 3px -2px #777;
padding: 3px;
width:80px;
}
.common_button_container
{
border: 1px solid;
width: 100px;
padding: 7px;
}
I am trying to create button-pressing effects. But I don't want this effect to affect it's container. i want to have only width and height reduced on button while pressing but not for the container. Any idea?
You could just hard set the height of the .common_button_container by adding height: 30px; to it.
If the size of the container is not specified, use this:
.common_button_placeholder
{
background-color: transparent;
color: transparent;
}
.common_button
{
position: absolute;
}
.common_button:active
{
box-shadow: 0px 3px 3px -2px #777;
padding: 3px;
width:80px;
}
.common_button_container
{
border: 1px solid;
width: 100px;
padding: 7px;
}
<div class="common_button_container">
<div class="common_button">Submit</div>
<div class="common_button_placeholder">Submit</div>
</div>
The common_button is set to absolute; common_button_placeholder not. So common_button_placeholder is behind the orginal, it set the size of the container, but common_button has no further effect to it.Just for the styling, how about using transition:
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;

Touchpoints on mouseover - 2 issues

I'd like to implement small circles (touch points) with a onmouse over effect (circles would become bigger on mouse over and contain a few lines of text) - see jsfiddle http://jsfiddle.net/eRDy6/1/
I've tried to adapt some code found on the web but struggling to do 2 things:
I can't get the word "read" centered (vertically and horizontally) to the middle of the circles. How could I achieve this.
I'd like a different text to be displayed onmouse over in the big circles. What would be the best way to do this?
Many thanks for your help
<div class="middle clear">
<div id="touchPointContainer">
<div id="touchPoint1" class="touchPoint">
<p>read</p>
</div>
<div id="touchPoint2" class="touchPoint">
<p>read</p>
</div>
<div id="touchPoint3" class="touchPoint">
<p>read</p>
</div>
</div>
</div><!-- End DIV Middle clear -->
CSS:
.middle {
display: block;
clear: both;
margin-right: auto;
margin-left: auto;
width: 980px;
background: red;
box-shadow: 0px 0px 10px 2px #e0e0e0;
-webkit-box-shadow: 0px 0px 10px 2px #e0e0e0;
-moz-box-shadow: 0px 0px 10px 2px #e0e0e0;
}
#touchPointContainer {
height: 600px;
background: green;
position: relative;
}
.touchPoint {
height: 60px;
width: 60px;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0px 0px 4px 6px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0px 0px 4px 6px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0px 0px 4px 6px rgba(0, 0, 0, 0.1);
-o-box-shadow: 0px 0px 4px 6px rgba(0, 0, 0, 0.1);
position: absolute;
text-align: center;
color: #5bb6e7;
font-size: 12px;
-webkit-transition: width .2s, height .2s, margin .2s;
-moz-transition: width .2s, height .2s, margin .2s;
-o-transition: width .2s, height .2s, margin .2s;
-ms-transition: width .2s, height .2s, margin .2s;
transition: width .2s, height .2s, margin .2s;
}
.touchPoint:hover {
height: 160px;
width: 160px;
margin: -40px 0px 0px -40px;
-webkit-transition: width .2s, height .2s, margin .2s;
-moz-transition: width .2s, height .2s, margin .2s;
-o-transition: width .2s, height .2s, margin .2s;
-ms-transition: width .2s, height .2s, margin .2s;
transition: width .2s, height .2s, margin .2s;
}
#touchPoint1 {
top: 260px;
left: 140px;
}
#touchPoint2 {
top: 240px;
left: 360px;
}
#touchPoint3 {
top: 180px;
left: 720px;
}
To vertically center text we need to set display: table-cell to the element and display: table to its container.
To switch contents on hover, you can make an hidden text element and show it when the container is being hovered (and hide the first one).
So to do what you want, add these classes:
.touchPoint {
display: table;
}
.touchPoint p {
vertical-align: middle;
display: table-cell;
}
.touchPoint .final,
.touchPoint:hover .initial {
display: none;
}
.touchPoint .initial,
.touchPoint:hover .final {
display: table-cell;
}
jsFiddle Demo