Div with Overflow : - html

I want to have 2 elements in a div but only one should be visible, and I want to have a vertical scrollbar.
Unfortunately, the second element is visible and there is no scrollbar.
#visu {
top:10px;
height:180px;
width:50%;
overflow:auto;
background-color:yellow;
}
#element1 {
position:absolute;
top:15px;
left:80px;
}
#element2 {
position:absolute;
top:200px;
left:80px;
}
.element {
margin-right:-50px;
}
.namecontainer {
display:flex;
border:4px solid #000033; border-radius:10px;
padding:10px; box-sizing:border-box;
background-color:white;
width:280px;
height:150px;
margin-left:0px;
align-items: center;
justify-content:center:
color:#1a1a1a;
}
.namecontainer p {
font-size:35px;
font-family: 'Arial';
font-weight:bold;
color:#1a1a1a;
text-align:center;
width:380px;
}
<div id="visu">
<div id="element1" class="element">
<div class="namecontainer">
<p class= "name" id="name1" >element 1</p>
</div>
</div>
<div id="element2" class="element">
<div class="namecontainer">
<p class= "name" id="name3" >element 2</p>
</div>
</div>
</div>

You need to play with margin and drop absolute positionnong cause it takes element off the flow and is not necessary here https://jsfiddle.net/vpdc5L4m/13/
#visu {
top: 10px;
height: 180px;
width: 50%;
overflow: auto;
background-color: yellow;
}
#element1 {}
#element2 {}
.element {
margin: 15px auto ;
}
.namecontainer {
display: flex;
border: 4px solid #000033;
border-radius: 10px;
padding: 10px;
box-sizing: border-box;
background-color: white;
width: 280px;
height: 150px;
margin:auto;
align-items: center;
justify-content: center: color: #1a1a1a;
}
.namecontainer p {
font-size: 35px;
font-family: 'Arial';
font-weight: bold;
color: #1a1a1a;
text-align: center;
width: 380px;
}
<div id="visu">
<div id="element1" class="element">
<div class="namecontainer">
<p class="name" id="name1">element 1</p>
</div>
</div>
<div id="element2" class="element">
<div class="namecontainer">
<p class="name" id="name2">element 2</p>
</div>
</div>
<div id="element3" class="element">
<div class="namecontainer">
<p class="name" id="name3">a third one ?</p>
</div>
</div>
</div>

To hide a CSS element, you can use
display: none;

Related

Why is my image style's applied to all images when I've specifically styled each?

I need "tumbnail.jpg" , "child.png" and "nanny.png" to be in square shape.
also "tumbnail.jpg" as a thumbnail. (It's already a thumbnail I guess)
other two I need them as just squared images side by side. Please help me with this. I tried to solve this since 4 days but I couldn't.
how should I style those 3 to be squared?
body { background-image: url( "bg.jpg" ); }
h2, p { text-align: center; }
.lulu{font-family:Copperplate, Papyrus, fantasy;
text-align: center;
font-weight: bolder;
}
.parent{ background-color:lightgrey;
width: 80%;
margin-left: auto;
margin-right: auto;
height:200px;}
.column {
float: left;
width: 30%;
padding: 5px;
}
.child-1{
background-color:lightgray;
width:73%;
float:center;
height:900px;
text-align:center;
padding-top:50px;
padding-bottom:50px;
padding-right:50px;
padding-left:50px;
margin-left:130px;
margin-right:150px;
margin-top:80px;
margin-bottom:80px;
}
.child-1 p {
color: white;
padding-left: 10px;
padding-right:10px;
padding-top: 50px;
text-align:center;
width:80%;}
.child-2{
background-color:aliceblue;
width:300px;
float:right;
height:400px;
margin:50px;
text-align:left;
padding-left:10px;}
.child-2 p{
color: black;
padding-left: 10px;
padding-right:10px;
padding-top: 50px;
text-align:left;
width:80%;}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href=styles.css>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<title>Daycare Center</title>
</head>
<body>
<div>
<div class="parent">
<header>
<h1 class="lulu"> DAYCARE</h1>
</header>
<style>
img {
border: 1px solid #ddd;
border-radius:2px;
padding: 5px;
max-width:auto;
max-height:auto;
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
<img src="tumbnail.jpg" alt="kids" style="width:100px" style="height:100px">
</div>
<div>
<div class="child-1">
<h3 style="color:white;">
Child care: Making the best choice
for your family</h3>
<p>.</p>
<div class="row">
<div class="column">
<style>
img {
border: 1px solid #ddd;
border-radius:50%;
padding: 5px;
max-width:auto;
max-height:auto;
}
</style>
<img src="house.jpg" alt="house" style="width:100px" style="height:100px">
</div>
<div class="column">
<style>
img {
border: 1px solid #ddd;
border-radius:50%;
padding: 5px;
max-width:auto;
max-height:auto;
}
</style>
<img src="heart.jpg" alt="heart" style="width:100px" style="height:100px">
</div>
<div class="column">
<style>
img {
border: 1px solid #ddd;
border-radius:50%;
padding: 5px;
max-width:auto;
max-height:auto;
}
</style>
<img src="feet.jpg" alt="feet" style="width:100px" style="height:100px">
</div>
<div class="row">
<div class="column">
<img src="child.png" alt="child" style="width:100%">
</div>
<div class="column">
<img src="nanny.png" alt="nanny" style="width:100%">
</div>
</div>
<div>
<div style="position:relative; right:8px; top:90px;">
<div class="child-2">
<h3>About us:</h3>
<p>.</p>
<h3>Our Service</h3>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
<main>
<section>
</section>
</main>
</div>
</body>
</html>
It is not ideal to use several differant styling options on one page.
It is recommened that all styling is maintained seperately from your pages code.
e.g by using a css.
Using the img tag in your css will affect ALL img tags in your code.
If you want to add additional specific changes to certain images then you should add a class e.g
<img class="fill"/>
.fill {
width:100%;
height:100%;
}
SPECIFICITY
If an item in your css is after a conflicting class the subsequent one will take priority as long as the element doesn't have a more dominat identifier.
You can read more about that here: https://www.w3schools.com/css/css_specificity.asp
For this example, having .fill after img will cause this image to be width and height 100% rather than 100px
EXAMPLE
img {
background:#cdf;
width:100px;
height:100px;
}
.fill {
width:100%;
height:100%;
}
<img src="https://i.stack.imgur.com/BxBTo.png">
<img class="fill" src="https://i.stack.imgur.com/BxBTo.png">
I recommend you clear the styling from your html and add it to your css.
body {
background-image: url("bg.jpg");
}
h2,
p {
text-align: center;
}
img {
border: 1px solid #ddd;
border-radius: 2px;
padding: 5px;
height: 100px;
width: 100px;
max-width: auto;
max-height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
.lulu {
font-family: Copperplate, Papyrus, fantasy;
text-align: center;
font-weight: bolder;
}
.parent {
background-color: lightgrey;
width: 80%;
margin-left: auto;
margin-right: auto;
height: 200px;
}
.column {
float: left;
width: 30%;
padding: 5px;
}
.child-1 {
background-color: lightgray;
width: 73%;
float: center;
height: 900px;
text-align: center;
padding-top: 50px;
padding-bottom: 50px;
padding-right: 50px;
padding-left: 50px;
margin-left: 130px;
margin-right: 150px;
margin-top: 80px;
margin-bottom: 80px;
}
.child-1 p {
color: white;
padding-left: 10px;
padding-right: 10px;
padding-top: 50px;
text-align: center;
width: 80%;
}
.child-2 {
background-color: aliceblue;
width: 300px;
float: right;
height: 400px;
margin: 50px;
text-align: left;
padding-left: 10px;
}
.child-2 p {
color: black;
padding-left: 10px;
padding-right: 10px;
padding-top: 50px;
text-align: left;
width: 80%;
}
<div>
<div class="parent">
<header>
<h1 class="lulu"> DAYCARE</h1>
</header>
<img src="tumbnail.jpg" alt="kids">
</div>
<div>
<div class="child-1">
<h3 style="color:white;">Child care: Making the best choice for your family</h3>
<p>.</p>
<div class="row">
<div class="column">
<img src="house.jpg" alt="house">
</div>
<div class="column">
<img src="heart.jpg" alt="heart">
</div>
<div class="column">
<img src="feet.jpg" alt="feet">
</div>
<div class="row">
<div class="column">
<img src="child.png" alt="child" style="width:100%">
</div>
<div class="column">
<img src="nanny.png" alt="nanny" style="width:100%">
</div>
</div>
<div>
<div>
<div class="child-2">
<h3>About us:</h3>
<p>.</p>
<h3>Our Service</h3>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
<main>
<section>
</section>
</main>
</div>
</div>
</div>
</div>

Add parent DIV css properties to child DIVs

I have a parent DIV wrap and 3 main child DIVs.inputQ,inputQL,inputQR. I am using a background color for wrap, but this color is not showing up for inputQL, inputQR.Since inputQL, inputQR are inside wrap, I believe its background color should be added to child one as well. I am a beginner in this area, can you please let me what is wrong here ? how can I add same background color for inputQL, inputQR ?
Fiddle : https://jsfiddle.net/anoopcr/hfmghkp0/
<div class="wrap">
<div class="inputQ">
<div class="InputQuest">Text Middle</div>
<div><input id="amnttext" class="textbox"></input></div>
</div>
<div class="inputQL">
<div class="InputQuest">Text Left</div>
<div><input id="loandtext" class="textbox"></input></div>
</div>
<div class="inputQR">
<div class="InputQuest">Text Right</div>
<div><input id="emidtext" class="textbox"></input></div>
</div>
</div>
CSS:
.wrap {
width: 80%;
margin-top: 80px;
margin: auto;
padding: 10px;
background:#eee;
}
.inputQ{width:60%;margin: auto; padding:10px;height:50px;margin-top:50px; }
.inputQL{width:45%;margin: auto; height:50px;margin-top:50px;float:left;}
.inputQR{width:45%;margin: auto; height:50px;margin-top:50px;float:right; }
.InputQuest
{
width:50%;
float:left;
font-family: arial;
font-size:18px;
text-align:center;
line-height: 30px;
margin:auto;
}
.textbox
{
float:left;
margin:auto;
font-size:16px;
font-family: verdana;
padding:5px;
border:1px solid #ccc;
border-radius:4px;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
width:30%;
}
You Also neede to cell .wrap { overflow: hidden; }
try this
.wrap {
width: 80%;
margin-top: 80px;
margin: auto;
padding: 10px;
background:#eee;
overflow: hidden;
}
.inputQ{width:60%;margin: auto; padding:10px;height:50px;margin-top:50px; }
.inputQL{width:45%;margin: auto; height:50px;margin-top:50px;float:left;}
.inputQR{width:45%;margin: auto; height:50px;margin-top:50px;float:right; }
.InputQuest
{
width:50%;
float:left;
font-family: arial;
font-size:18px;
text-align:center;
line-height: 30px;
margin:auto;
}
.textbox
{
float:left;
margin:auto;
font-size:16px;
font-family: verdana;
padding:5px;
border:1px solid #ccc;
border-radius:4px;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
width:30%;
}
<div class="wrap">
<div class="inputQ">
<div class="InputQuest">Text Middle</div>
<div><input id="amnttext" class="textbox"></input></div>
</div>
<div class="inputQL">
<div class="InputQuest">Text Left</div>
<div><input id="loandtext" class="textbox"></input></div>
</div>
<div class="inputQR">
<div class="InputQuest">Text Right</div>
<div><input id="emidtext" class="textbox"></input></div>
</div>
</div>

CSS and HTML for this below view

I am left with 2 labels and can't find solution.
I have done this much HTML and CSS
<div id="incoming_call" class="bottom_toolbar_incoming_call" style="bottom:90px; position: fixed; right: 3px; z-index: 9999; height:45px; width:250px; background-color:lightgray;">
<img src="http://findicons.com/files/icons/766/base_software/128/circle_red.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:200px; position: relative;" id="Reject" />
<img src="http://findicons.com/files/icons/766/base_software/128/circle_green.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:100px; position: relative;" id="answer" />
</div>
I would put the images inside a position:absolute div like this
#incoming_call{
border: 2px solid black;
}
#call{
color:green;
}
#images{
position:absolute;
top:0px;
}
<div id="incoming_call" class="bottom_toolbar_incoming_call" style="bottom:90px; position: fixed; right: 3px; z-index: 9999; height:45px; width:250px; background-color:lightgray;">
<div id="call">call from 7040</div>
<div id="time">0:01</div>
<div id="images">
<img src="http://findicons.com/files/icons/766/base_software/128/circle_red.png" alt="Reject" style=" width:40px; height:40px; display: inline-block; padding:2px; left:200px; position: relative;" id="Reject" />
<img src="http://findicons.com/files/icons/766/base_software/128/circle_green.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:100px; position: relative;" id="answer" />
</div>
</div>
Try this way:
Takes care of vertical alignment (as it appears in your design)
Content height adjusts according to adjacent column
No browser issues as well
Red and Green color using CSS - Hence no images required
.parent-container {
width: 320px;
}
.box {
border: 2px solid #000;
display: table;
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.box__cell {
display: table-cell;
width: 50%;
vertical-align: middle;
padding: 0 15px;
}
ul {
padding: 0;
list-style-type: none;
}
.circle {
width: 20px;
height: 20px;
border-radius: 50%;
border: 2px solid #000;
}
.b-red {
background: red;
}
.b-green {
background: green;
}
.t-green {
color: green;
}
.text-right {
text-align: right;
}
.list-item li {
display: block;
}
.list-inline li {
display: inline-block;
}
<div class="parent-container">
<div class="box">
<div class="box__cell box__cell--left">
<div id="incoming_call">
<ul class="list-item">
<li class="t-green">Incoming Call</li>
<li><b>00: 05</b></li>
</ul>
</div>
</div>
<div class="box__cell box__cell--left">
<ul class="list-inline text-right">
<li class="circle b-red">
</li>
<li class="circle b-green">
</li>
</ul>
</div>
</div>
</div>

Boostrap side by side grid, in fixed space

I'm trying to pack the pictures in
<div class="social block"> ... </div>
appear to be side by side, like a grid. I'm also trying to make it completely fluid, and self-adjusting (hence Bootstrap).
I want two make a total of two rows that will have 3 icons in each, with all of the images touching on the sides.
It currently looks like this: http://postimg.org/image/z0g80wf0z/
Here is my CSS:
// Place all the styles related to the Pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
p{
color: rgb(51, 51, 51);
display: block;
font-family: Roboto, sans-serif;
font-size: 21px;
font-weight: 100;
height: 90px;
line-height: 30px;
margin-bottom: 10px;
margin-left: 0px;
margin-right: 0px;
margin-top: 30px;
text-align: center;}
p, h1 { margin: 0 }
html {
position:relative;
height:100%;
width:100%;
}
html,body
{
margin: 0px;
padding: 0px;
overflow-x: hidden;
}
body {
position:absolute;
min-width:100%;
min-height:100%;
}
.window {
height:700px;
width:100%;
//border-top: solid 1px #000; //temp test
}
.full{
width:100%;
}
.main-home {
background: url('http://i58.tinypic.com/2v34yub.jpg') no-repeat center center;
background-size:cover;
}
.main-about {
background: url('https://static.pexels.com/photos/1440/city-road-street-buildings.jpg') no-repeat center center;
background-size:cover;
}
.window-support {
padding: 80px 0;
text-align: center;
}
.content {
top:225px;
position:relative;
text-align: center;
color: white;
}
h1.headline {
font-family: 'Roboto', sans-serif;
font-weight: 100;
font-size: 50px;
}
h2.headline {
font-family: 'Roboto', sans-serif;
font-weight: 100;
font-size: 35px;
}
.btn.sharp {
border-radius:0;
border:none;
font-size: 14px;
}
.menu-icon {
top:30px;
left:30px;
position:absolute;
margin: 0;
}
.col-centered{
float: none;
margin: 0 auto;
}
.halfBack {
width: 50%;
height:500px;
}
.grid-text {
padding-top:205px;
}
.text-background {
height: 2em;
width: 100%;
background-color:#000;
line-height:2em;
vertical-align:middle;
text-align:center;
opacity:0.7;
}
#footer {
background-color: #f9f9f9;
border-top: solid 1px #F5F5F5;
height:50px;
text-align: center;
line-height:50px;
vertical-align:middle;
color: #ccc;
position:absolute;
bottom:-50px;
width:100%;
}
#abt-grid-3 {
background: url('https://paulkporterphotography.files.wordpress.com/2015/04/20141210-distillery-31.jpg') no-repeat center center;
height:500px;
background-size:cover;
border: solid 2px #F5F5F5;
}
#abt-grid-1{
background:url('https://i0.wp.com/upload.wikimedia.org/wikipedia/commons/1/14/1_yonge_street_toronto_winter_2010_panorama.jpg') no-repeat center center;
height:500px;
background-size:cover;
border: solid 2px #F5F5F5;
}
#abt-grid-2{
background: url('http://ryersonbuilds.ryerson.ca/wp-content/uploads/2013/12/X6C61871.jpg') no-repeat center center;
height:500px;
border: solid 2px #F5F5F5;
background-size:cover;
}
#leftHalf {
background: url(images/bg-1.jpg);
width: 70%;
position: absolute;
left: 0px;
height: 100%;
}
#rightHalf {
background: url(images/bg-2.jpg);
width: 30%;
position: absolute;
right: 0px;
height: 100%;
}
.socialBlock{
border: solid 1px #CCC;
height: 300px;
width:100%;
}
.edgeWrap {
margin:0px;
padding:0;
width:100%;
}
.socialBlock {
.row {border:solid 1px #000;}
.col-md-4 {}
.container{width:auto;}
}
Here is the html:
<!DOCTYPE html>
<html>
<!-- start page -->
<div id="leftHalf" class="halfBack">
<div class="window main-home">
<div class="container edgeWrap">
<!-- content -->
<div class="row">
<div class="content col-md-12">
<h1 class="headfont text-center white" data-sr="flip 65deg over 2s" >Hi, I'm Satchel.</h1>
<p data-sr="flip 65deg over 2s"> <%= link_to 'About Me', '/about', class:'btn btn-primary sharp btn-lg', role:'button' %>
<%= link_to 'The Blog', '/blog', class:'btn btn-primary sharp btn-lg', role:'button', target:'_blank' %>
</p>
</div>
</div>
</div>
</div>
</div>
<div id = "rightHalf" class="halfBack">
<div class="container edgeWrap">
<div class="row">
<div class="col-md-12">
<div class="socialBlock">
<div class="container">
<div class="row">
<div class="col-md-4"> <%= image_tag('icon/youtube-play.png',class:'img-responsive') %> </div>
<div class="col-md-4"> <%= image_tag('icon/twitter.png', class:'img-responsive') %> </div>
<div class="col-md-4"> <%= image_tag('icon/twitter.png', class:'img-responsive') %> </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</html>
It's a little weird, because I'm trying to do a split (originally two halves now 3/10 and 7/10).
Any help is appreciated!
Satchel Hi there.
Have a look at this Fiddle to see if it helps you here.
I just tried to simplify this a bit, so if you wanted to run the Bootstrap way here.
You can always see how this works and replace the col-xs-xx with you own css. If you do not want to use Bootstrap.
You said you are wanting to have two rows each with 3 images all touching.
I did that this way.
<div class="col-xs-3">
<div class="row">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
</div>
<div>
<div class="row padtop">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
<img src="http://www.freelargeimages.com/wp-content/uploads/2015/05/Twitter_Logo_Hd_Png_03.png" class="col-xs-4 no-pad-marg">
</div>
</div>
</div>

Five Buttons with Overlapping text

I'm building the following (see image). Basically, I need 5 buttons with overlapping buttons (each with numbers) on the top. However, I'm unsure how to go about this?
One solution:
https://jsfiddle.net/ryd5e51n/
<div class="button">
<div class="button-top"><span class="text">1</span></div>
<div class="button-bottom"></div>
</div>
.button
{
display: table;
}
.button-top
{
background-color: black;
width: 36px;
height: 36px;
border-radius: 18px;
margin: auto;
position: relative;
z-index: 2;
box-shadow: 0px 0px 2px 2px #bbbbbb;
color: white;
text-align: center;
}
.text
{
display: block;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.button-bottom
{
background-color: #efefef;
width: 100px;
height: 90px;
margin-top: -15px;
position: relative;
z-index: 1;
border: 2px solid #bbbbbb;
border-radius: 20px;
}
You can do this with a single element:
HTML:
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
CSS:
div.button {
display:block;
float:left;
margin:18px 5px 0;
position:relative;
overflow:visible;
background:none #efefef;
width:100px;
height:100px;
border:2px solid #ccc;
border-radius:10px;
counter-increment: button;
}
div.button:before {
content:counter(button);
display:block;
padding:8px 14px;
background:none #000;
border:2px solid #ccc;
border-radius:100px;
color:#fff;
position:absolute;
left:50%;
top:-18px;
transform: translateX(-50%);
}
See fiddle: https://jsfiddle.net/jj2nk5f1/2/
Here it is.
.button {
float: left;
margin-left: 10px;
}
.number {
width: 20px;
height: 20px;
border-radius: 10px;
background-color: black;
margin-left: 15px;
}
.block {
width: 50px;
height: 50px;
border: 1px solid black;
margin-top: -10px;
}
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>