.....................................................................................................................................................................
i want to set height auto of div follow data , how can i set ?
.....................................................................................................................................................................
<div style="
width: 100%;
">
<div style="
margin: 0;
padding: 0;
height: 48px;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
background: #f5f5f5;
border-bottom: 1px #ccc solid;
width: 100%;
-webkit-box-shadow: 0 0 3px 1px rgba(0,0,0,0.15);
-moz-box-shadow: 0 0 3px 1px rgba(0,0,0,0.15);
box-shadow: 0 0 3px 1px rgba(0,0,0,0.15);
display: block;
">
<div style="
margin: 0 auto;
width: 992px;
height: 48px;
">
<div style="
margin-top: 0px;
height: 48px;
text-align: center;
float: left;
width: 100%;
line-height: 48px;
">
<div style="
margin-top: 0px;
height: 48px;
text-align: center;
float: left;
line-height: 48px;
width: 50%;
">
kkkkkkkk
<br>
kkkkkkkk
<br>
kkkkkkkk
<br>
kkkkkkkk
</div>
<div style="
margin-top: 0px;
text-align: center;
float: right;
line-height: 48px;
width: 50%;
">
kkkkkkkk
</div>
</div>
</div>
</div>
</div>
I think I know what you want. Not 100% sure as you have not made much sense.
I started by making a id for each of your div because having that much inline styling is just silly.
HTML:
<div style="width: 100%;">
<div id="innerdiv">
<div id="innerdiv2">
<div id="innerdiv3">
<div id="innerdiv4">Testing
<br />Test info
<br />Test info
<br />Test info</div>
<div id="innerdiv5">Testing</div>
</div>
</div>
</div>
</div>
CSS:
#innerdiv {
margin: 0;
padding: 0;
height: auto;
overflow: hidden;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
background: #f5f5f5;
border-bottom: 1px #ccc solid;
width: 100%;
-webkit-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.15);
display: block;
}
#innerdiv2 {
margin: 0 auto;
width: 992px;
height: auto;
}
#innerdiv3 {
margin-top: 0px;
height: auto;
text-align: center;
float: left;
width: 100%;
line-height: 48px;
}
#innerdiv4 {
margin-top: 0px;
height: auto;
text-align: center;
float: left;
line-height: 48px;
width: 50%;
}
#innerdiv5 {
margin-top: 0px;
text-align: center;
float: right;
line-height: 48px;
width: 50%;
}
Now what you are looking for (I think) is overflow: hidden; You are floating the inner divs so there height wasn't being counted in the parent div. Adding the overflow to #innerdiv solves this problem.
DEMO HERE
Related
I'm trying to do a simple grid for my website. I could almost successfully do what I wanted.
I would like to fix the "Projects" that is the title of this grid, I would like to have it not in the same size as the other parts of the grid.
This is the result that I have:
I would like to have something like this:
HTML:
<div class="project-container">
<div className="title">
<h1>PROJECTS</h1>
</div>
<div className="project-one item">
<h2>Face Recognition</h2>
<button className="button button1">VIEW PROJECT</button>
</div>
<div className="project-two item">
<h2>Face Recognition</h2>
<button className="button button1">VIEW PROJECT</button>
</div>
<div className="project-three item">
<h2>Face Recognition</h2>
<button className="button button1">VIEW PROJECT</button>
</div>
</div>
CSS:
.project-container {
width: 80%;
height: 80vh;
margin: auto;
display: grid;
border: 1px solid pink;
// grid-gap: 4em;
grid-template-columns: repeat(3, 1fr);
grid-template-areas:
"t t t"
"p1 p2 p3";
}
.item {
// width: 100%;
// height: 100%;
// transition: all 0.2s ease-in-out;
text-align: center;
color: white;
border: 1px solid pink;
}
.title {
grid-area: t;
text-align: center;
border: 1px solid pink;
// height: 10vh;
}
use grid-template-rows
.project-container {
width: 80%;
height: 80vh;
margin: auto;
display: grid;
border: 1px solid pink;
// grid-gap: 4em;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 100px auto;
grid-template-areas:
"t t t"
"p1 p2 p3";
}
Dude I would recommend using css flexbox. See I have made a code that might help you & it's fully responsive. If you want to create a heavy masonry layout you can go for css grid.
.project_container {
padding: 20px;
margin-bottom: 2em;
position: relative;
max-width: 900px;
margin-left: auto;
margin-right: auto;
background-color: #f7f7f7;
border-radius: 7px;
box-sizing: border-box;
font: normal 16px/1.9em sans-serif;
}
.wrap {
color: #292929;
font-size: 18px;
line-height: 1.8em;
border: 0;
vertical-align: baseline;
margin: 0;
background-color: #f7f7f7;
border-radius: 3px;
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.title {
background-color: #a2cbfa;
border: 1px solid #4390e1;
text-align: center;
font-size: 18px;
color: black;
-webkit-text-fill-color: #a2cbfa;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: black;
vertical-align: center;
box-sizing: border-box;
box-shadow: 0 2px 2px rgba(0, 90, 250, 0.05), 0 4px 4px rgba(0, 90, 250, 0.05),
0 8px 8px rgba(0, 90, 250, 0.05), 0 16px 16px rgba(0, 90, 250, 0.05);
height: 100%;
margin-bottom: 2%;
width: 100%;
}
.item {
color: #292929;
font-size: 18px;
line-height: 1.8em;
vertical-align: baseline;
border-radius: 3px;
background-color: #a2cbfa;
-webkit-text-fill-color: #a2cbfa;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: black;
border: 1px solid #4390e1;
box-sizing: border-box;
box-shadow: 0 2px 2px rgba(0, 90, 250, 0.05), 0 4px 4px rgba(0, 90, 250, 0.05),
0 8px 8px rgba(0, 90, 250, 0.05), 0 16px 16px rgba(0, 90, 250, 0.05);
height: 250px;
margin-bottom: 2%;
text-align: center;
margin-right: 2%;
flex-grow: 1;
}
.project-three {
margin-right: 0px;
}
button {
outline: none;
border: none;
border-radius: 3px;
padding: 5px 10px;
font-weight: light;
-webkit-text-fill-color: #292929;
color: #292929;
-webkit-text-stroke-width: 0px;
-webkit-text-stroke-color: none;
font-size: 12px;
letter-spacing: 1px;
}
<div class="project_container">
<div class="wrap">
<div class="title">
<h1>PROJECTS</h1>
</div>
<div class="project-one item">
<h2>Face Recog</h2>
<button class="button button1">VIEW</button>
</div>
<div class="project-two item">
<h2>Face Recog</h2>
<button class="button button1">VIEW</button>
</div>
<div class="project-three item">
<h2>Face Recog</h2>
<button class="button button1">VIEW</button>
</div>
</div>
</div>
HAPPY CODING
Regards Sameer
I have a div that i don't know how to allign to the bottom of its parent.
I tried with bottom: 0 and margin-bottom: 0 but both doesn't work. I played with position aswell and it doesn't change anything only the absolute position makes the div stick to the very bottom of the page. Vertical-align doesn't seem to work aswell.
Here's a simplified version of my code:
.category{
height: 70px !important;
width: 28% !important;
margin: 0 10px 0 10px;
border: 1px solid #3A94D7;
border-radius: 15px;
box-shadow: 0 0 15px 1px rgba(0,0,0,.75), inset 0 0 2px 0 #4293D5;
}
.icon-steam{
background: url(../img/steam.png) 50% 50% no-repeat;
background-size: 40px;
float: left;
width: 40px;
height: 40px;
margin-right: 0.3em;
}
.platform{
text-shadow: none;
color: #65a1bf;
text-align: center;
bottom: 0;
position: relative;
margin-bottom: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="categories">
<div class="category icon-steam"><div class="platform">Steam</div></div>
</div>
And there's a fiddle link if you want: https://jsfiddle.net/kk8Lwh6v/
Can someone help me please?
Add position:absolute on the element that you want to align and add position:relative on its parent.
.category {
height: 70px !important;
width: 28% !important;
margin: 0 10px 0 10px;
border: 1px solid #3A94D7;
border-radius: 15px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, .75), inset 0 0 2px 0 #4293D5;
position: relative;
}
.icon-steam {
background: url(../img/steam.png) 50% 50% no-repeat;
background-size: 40px;
float: left;
width: 40px;
height: 40px;
margin-right: 0.3em;
}
.platform {
width: 100%;
text-shadow: none;
color: #65a1bf;
text-align: center;
bottom: 0;
position: absolute;
margin-bottom: 0;
}
<div class="categories">
<div class="category icon-steam">
<div class="platform">Steam</div>
</div>
</div>
You can use flexbox properties:
.category {
height: 70px !important;
width: 28% !important;
margin: 0 10px 0 10px;
border: 1px solid #3A94D7;
border-radius: 15px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, .75), inset 0 0 2px 0 #4293D5;
}
.icon-steam {
background: url(../img/steam.png) 50% 50% no-repeat;
background-size: 40px;
float: left;
width: 40px;
height: 40px;
margin-right: 0.3em;
display: flex;
justify-content: center;
}
.platform {
text-shadow: none;
color: #65a1bf;
margin-top: auto;
}
<div class="categories">
<div class="category icon-steam">
<div class="platform">Steam</div>
</div>
</div>
This will do.
.category{
height: 70px !important;
width: 28% !important;
margin: 0 10px 0 10px;
border: 1px solid #3A94D7;
border-radius: 15px;
box-shadow: 0 0 15px 1px rgba(0,0,0,.75), inset 0 0 2px 0 #4293D5;
}
.icon-steam{
background: url(../img/steam.png) 50% 50% no-repeat;
background-size: 40px;
float: left;
width: 40px;
height: 40px;
margin-right: 0.3em;
}
.platform{
text-shadow: none;
color: #65a1bf;
left:14%;
top:60px;
position: absolute;
}
<div class="categories">
<div class="category icon-steam"><div class="platform">Steam</div></div>
</div>
.category{
height: 70px !important;
width: 28% !important;
margin: 0 10px 0 10px;
border: 1px solid #3A94D7;
border-radius: 15px;
box-shadow: 0 0 15px 1px rgba(0,0,0,.75), inset 0 0 2px 0 #4293D5;
}
.icon-steam{
background: url(../img/steam.png) 50% 50% no-repeat;
background-size: 40px;
float: left;
width: 40px;
height: 40px;
margin-right: 0.3em;
}
.platform{
text-shadow: none;
color: #65a1bf;
text-align: center;
top: 60px;
left:14%;
position: absolute;
margin-bottom: 0;
}
<div class="categories">
<div class="category icon-steam"><div class="platform">Steam</div></div>
</div>
I'm trying to resize the font to the container, to be kept in a single line not matter how long is, just by resizing it's font.
this is what I'm talking about
#project_stats{
padding: 0;
width: 320px;
margin: 0;
border-right: 1px solid #ccc;
pr1 {
font-size: 2vw; overflow: hidden;
letter-spacing: -1px;
font-weight: normal;
padding: 0px;
margin: 0px;
color: black;
}
}
Any ideas?
---- EDIT 1 ------
Html.
<% provide(:title, #project.name) %>
<div class="row">
<div class="col-md-12" id="project_canvas">
<div class="row">
<div class = "col-md-3" id="project_stats">
<pr1><%= #project.name %></pr1>
........
Update to CSS
#project_canvas{
background: white;
width: 1600px;
margin-left: auto;
margin-right: auto;
margin-bottom: auto;
border-radius: 10px;
padding: 30px;
box-shadow: rgb(150,150,150) 5px 5px 10px;
#project_stats{
padding: 0;
width: 320px;
margin: 0;
border-right: 1px solid #ccc;
pr1 {
font-size: 2vw; overflow: hidden;
letter-spacing: -1px;
font-weight: normal;
padding: 0px;
margin: 0px;
color: black;
}
}
}
Good day to everyone. Just don't know how to remove central part of div#additionalBorder. I thought I could do it with inner div#partition but got stuck. Is it possible to do it in such way?
Or may be I should use pseudo elements ::before.
Here 's screen of what I mean:
#outerCircle {
display: flex;
flex-wrap: wrap;
margin: 0 auto;
width: 560px;
border: 2px dotted grey;
position: relative;
}
.bigButton {
height: 250px;
width: 250px;
border: solid #464646;
}
#greenButton {
background-color: #23a846;
border-radius: 100% 0 0 0;
border-width: 20px 10px 10px 20px;
}
#redButton {
background-color: #a50005;
border-radius: 0 100% 0 0;
border-width: 20px 20px 10px 10px;
}
#yellowButton {
background-color: #a7a408;
border-radius: 0 0 0 100%;
border-width: 10px 10px 20px 20px;
}
#blueButton {
background-color: #162da7;
border-radius: 0 0 100% 0;
border-width: 10px 20px 20px 10px;
}
div#innerCircle {
border: 15px solid #464646;
border-radius: 50%;
position: absolute;
top: 25%;
right: 25%;
background-color: aliceblue;
}
div.additionalBorder {
margin: 4px;
border: 2px solid black;
border-radius: 50%;
height: 238px;
width: 238px;
overflow: hidden;
}
p#tradeMark {
margin: auto;
height: 102px;
text-align: center;
font-size: 68px;
font-family: myDirector;
color: aliceblue;
background-color: black;
border-color: antiquewhite;
line-height: 140px;
}
span#reg {
font-size: 9px;
}
.partition {
height: 7px;
}
.buttons {
height: 130px;
border-top: 2px solid black;
display: flex;
flex-direction: column;
justify-content: space-around;
}
<div id="outerCircle">
<div class="bigButton" id="greenButton"></div>
<div class="bigButton" id="redButton"></div>
<div class="bigButton" id="yellowButton"></div>
<div class="bigButton" id="blueButton"></div>
<div class="bigButton" id="innerCircle">
<div class="additionalBorder">
<p id="tradeMark">simon<span id="reg">®</span>
</p>
<div class="partition"></div>
<div class="buttons"></div>
</div>
</div>
i just change this classes. i removed border from "div.additionalBorder" and add border, border-radius to ".buttons".
div.additionalBorder {
border-radius: 50%;
margin: 4px;
height: 242px;
width: 242px;
overflow: hidden;
}
.buttons {
border: 2px solid black;
border-radius: 0 0 130px 130px;
height: 130px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
#outerCircle {
display: flex;
flex-wrap: wrap;
margin: 0 auto;
width: 560px;
border: 2px dotted grey;
position: relative;
}
.bigButton {
height: 250px;
width: 250px;
border: solid #464646;
}
#greenButton {
background-color: #23a846;
border-radius: 100% 0 0 0;
border-width: 20px 10px 10px 20px;
}
#redButton {
background-color: #a50005;
border-radius: 0 100% 0 0;
border-width: 20px 20px 10px 10px;
}
#yellowButton {
background-color: #a7a408;
border-radius: 0 0 0 100%;
border-width: 10px 10px 20px 20px;
}
#blueButton {
background-color: #162da7;
border-radius: 0 0 100% 0;
border-width: 10px 20px 20px 10px;
}
div#innerCircle {
border: 15px solid #464646;
border-radius: 50%;
position: absolute;
top: 25%;
right: 25%;
background-color: aliceblue;
}
div.additionalBorder {
border-radius: 50%;
margin: 4px;
height: 242px;
width: 242px;
overflow: hidden;
}
p#tradeMark {
margin: auto;
height: 102px;
text-align: center;
font-size: 68px;
font-family: myDirector;
color: aliceblue;
background-color: black;
border-color: antiquewhite;
line-height: 140px;
}
span#reg {
font-size: 9px;
}
.partition {
height: 7px;
}
.buttons {
border: 2px solid black;
border-radius: 0 0 130px 130px;
height: 130px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
<div id="outerCircle">
<div class="bigButton" id="greenButton"></div>
<div class="bigButton" id="redButton"></div>
<div class="bigButton" id="yellowButton"></div>
<div class="bigButton" id="blueButton"></div>
<div class="bigButton" id="innerCircle">
<div class="additionalBorder">
<p id="tradeMark">simon<span id="reg">®</span>
</p>
<div class="partition"></div>
<div class="buttons"></div>
</div>
</div>
I'm trying to arrange images like the picture below? I'm already try float left, but it didn't display as picture below.
CSS can't do it, you need JavaScript.
Specifically jQuery, and then jQuery Masonry.
Alternatively, if you'd prefer to stick to raw JavaScript, you can use Vanilla Masonry.
Take a look at the images demo: http://masonry.desandro.com/demos/images.html
Pure CSS, tested in Internet Explorer, Fire Fox, and Opera:
<style type="text/css">
/*<![CDATA[*/
.A {
float: left;
margin: 0px 6px 0px 0px;
}
.A1 {
border: 1px solid black;
float: left;
width: 100px;
height: 74px;
margin: 0px 0px 6px 0px;
}
.A2 {
border: 1px solid black;
float: left;
width: 100px;
height: 83px;
clear: left;
}
.B {
float: left;
margin: 0px 6px 0px 0px;
}
.B1 {
border: 1px solid black;
float: left;
width: 100px;
height: 47px;
margin: 0px 0px 6px 0px;
}
.B2 {
border: 1px solid black;
float: left;
width: 100px;
height: 126px;
clear: left;
}
.C {
float: left;
margin: 0px 6px 0px 0px;
}
.C1 {
border: 1px solid black;
float: left;
width: 100px;
height: 107px;
margin: 0px 0px 6px 0px;
}
.C2 {
border: 1px solid black;
float: left;
width: 100px;
height: 49px;
clear: left;
}
.D {
float: left;
margin: 0px 6px 0px 0px;
}
.D1 {
border: 1px solid black;
float: left;
width: 316px;
height: 60px;
margin: 0px 0px 6px 0px;
}
.D2 {
}
.D2A {
border: 1px solid black;
float: left;
width: 100px;
height: 86px;
clear: left;
margin: 0px 6px 6px 0px;
}
.D2B {
border: 1px solid black;
float: left;
width: 100px;
height: 116px;
margin: 0px 6px 6px 0px;
}
.D2C {
border: 1px solid black;
float: left;
width: 100px;
height: 131px;
margin: 0px 0px 6px 0px;
}
.E {
border: 1px solid black;
float: left;
width: 100px;
height: 202px;
}
/*]]>*/
</style>
<div class="A">
<div class="A1">
A1
</div>
<div class="A2">
A2
</div>
</div>
<div class="B">
<div class="B1">
B1
</div>
<div class="B2">
B2
</div>
</div>
<div class="C">
<div class="C1">
C1
</div>
<div class="C2">
C2
</div>
</div>
<div class="D">
<div class="D1">
D1
</div>
<div class="D2">
<div class="D2A">
D2
</div>
<div class="D2B">
D3
</div>
<div class="D2C">
D4
</div>
</div>
</div>
<div class="E">
E
</div>