What I already have:
.modal-m1
{
background-image: url(../images/bg-greyout.png);
background-repeat: repeat;
display: table;
top: 0;
left: 0;
width: 100%;
height: 100%;
position: fixed;
margin: 0;
padding: 0;
z-index: 1;
}
.modal-m1 .modal-m2
{
display: table-cell;
vertical-align: middle;
}
.dialogbox
{
margin: 0 auto;
background-color: #F6F6F6;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
-webkit-box-shadow: #666 3px 3px 5px;
-moz-box-shadow: #666 3px 3px 5px;
box-shadow: #666 3px 3px 20px;
padding: 20px;
}
.mydialogbox
{
width: 400px;
}
<div class="modal-m1">
<div class="modal-m2">
<div class="dialogbox mydialogbox">
... CONTENT IS HERE ......
</div>
</div>
</div>
Everything is okay on that stage. You may test it on snippet.
Now I want to put several dialog boxes to different pages. I'm trying to reuse the code and for that reason I'm trying to extract modal-m1, modal-m2 and dialogbox to ASP.NET user control. mydialogbox must become a nested div inside of dialogbox. But dialogbox ignores width: 400px in this case. Is there any workaround?
In other words, I want my markup to be:
<div class="modal-m1">
<div class="modal-m2">
<div class="dialogbox">
<div class="mydialogbox">
... CONTENT IS HERE ......
</div>
</div>
</div>
</div>
Is it possible?
if I undestood..
your html can be like this:
<div class="modal-m1">
<div class="modal-m2">
<div class="dialogbox ">
<div class="mydialogbox">
<div>CONTENT IS HERE ......</div>
</div>
</div>
</div>
</div>
and you want put width only for .mydialogbox
.modal-m1 .modal-m2
{
display: table-cell;
vertical-align: middle;
text-align:center; /*add*/
}
.dialogbox
{
margin: 0 auto;
background-color: #F6F6F6;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
-webkit-box-shadow: #666 3px 3px 5px;
-moz-box-shadow: #666 3px 3px 5px;
box-shadow: #666 3px 3px 20px;
padding: 20px;
display:inline-block; /*change*/
}
.mydialogbox
{
width: 400px;
text-align:left
}
is this?
Related
I'm stumbling on a problem with some divs that have contenteditable set to true. Whenever i add text into the divs, they jump to a new position. Only when all divs are empty or all are filled with text, they have the same relative position.
You can find a JSfiddle with the code here.
What am i doing wrong?
Here is the code:
.editor_table {
position: relative;
display: table;
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.editor_row {
display: table-row;
}
.editor_cell {
display: table-cell;
border: none;
border-spacing: 5px;
width: 22%;
padding: 0px;
}
.editor_onvoldoende {
background: #F00
}
.editor_voldoende {
background: #FF0;
}
.editor_goed {
background: #0F0;
}
.editor_uitstekend {
background: #1B1;
}
.editor_onvoldoendead {
background: #F00
}
.editor_voldoendead {
background: #FF0;
}
.editor_goedad {
background: #0F0;
}
.editor_uitstekendad {
background: #1B1;
}
.editor_subject {
position: relative;
display: table-cell;
border: none;
width: 100px;
padding: 10px;
vertical-align: middle;
}
.editor_subject_input {
position: relative;
width: 100%;
border: none;
box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.05), 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
.editor_inner_cell {
margin: 5px;
height: 90px;
box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.05), 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
.editor_textarea {
position: relative;
height: 100%;
width: 100%;
border: none;
}
<div class="editor_table">
<div id="editor_a1" class="editor_row">
<div class="editor_subject">
<h3>
<input type="text" name="editor_subject1" class="editor_subject_input">
</h3>
</div>
<div id="editor_io" class="editor_cell">
<div id="editor_io_content" class="editor_onvoldoendead editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_iv" class="editor_cell">
<div id="editor_iv_content" class="editor_voldoendead editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_ig" class="editor_cell">
<div id="editor_ig_content" class="editor_goedad editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_iu" class="editor_cell">
<div id="editor_iu_content" class="editor_uitstekendad editor_inner_cell" contenteditable="true">
</div>
</div>
</div>
</div>
Replace your css class with below mention: I have added "float:left" and increased your width.
.editor_cell {
display: table-cell;
border: none;
border-spacing: 5px;
width: 24%;
padding: 0px;
float: left;
}
/* ------------------ */
/* CSS for the editor */
/* ------------------ */
.editor_table {
position: relative;
display: flex;
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.editor_row {
display: flex;
}
.editor_cell {
border: none;
border-spacing: 5px;
width: 22%;
padding: 0px;
width: 90px;
}
.editor_onvoldoende {
background: #F00
}
.editor_voldoende {
background: #FF0;
}
.editor_goed {
background: #0F0;
}
.editor_uitstekend {
background: #1B1;
}
.editor_onvoldoendead {
background: #F00
}
.editor_voldoendead {
background: #FF0;
}
.editor_goedad {
background: #0F0;
}
.editor_uitstekendad {
background: #1B1;
}
.editor_subject {
position: relative;
border: none;
width: 100px;
padding: 10px;
vertical-align: middle;
}
.editor_subject_input {
position: relative;
width: 100%;
border: none;
box-shadow: 5px 5px 10px 0px rgba(0,0,0,0.05),0px 0px 10px 0px rgba(0,0,0,0.1);
}
.editor_inner_cell {
margin: 4px;
height: 90px;
box-shadow: 5px 5px 10px 0px rgba(0,0,0,0.05),0px 0px 10px 0px rgba(0,0,0,0.1);
}
.editor_textarea {
position: relative;
height: 100%;
width: 100%;
border: none;
}
<div class="editor_table">
<div id="editor_a1" class="editor_row">
<div class="editor_subject">
<h3>
<input type="text" name="editor_subject1" class="editor_subject_input">
</h3>
</div>
<div id="editor_io" class="editor_cell">
<div id="editor_io_content" class="editor_onvoldoendead editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_iv" class="editor_cell">
<div id="editor_iv_content" class="editor_voldoendead editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_ig" class="editor_cell">
<div id="editor_ig_content" class="editor_goedad editor_inner_cell" contenteditable="true">
</div>
</div>
<div id="editor_iu" class="editor_cell">
<div id="editor_iu_content" class="editor_uitstekendad editor_inner_cell" contenteditable="true">
</div>
</div>
</div>
</div>
If you are able to make the switch, I would strongly recommend display: flexto solve this problem.
Normally the elements of an HTML markup appear in the order they are written in the markup file, and the inline elements appear from left to right.
But I want the children of a certain div (only, NOT all the elements of the entire page) to appear from right to left.
In case you wonder why it is needed, I want to do this to solve the following problem:
PROBLEM:
JSFiddle here.
.wrapper {
height: 100%;
width: 826px;
margin: 50px auto;
display: table;
background-color: #003b80;
}
.cell {
display: table-cell;
vertical-align: top;
}
.left-cell {
width: 50%;
background-color: chocolate;
}
.right-cell {
background-color: darkslategrey
}
.step-container {
max-height: 200px;
font-size: 0;
}
.right-cell .step-container {
margin-top: 125px;
}
.content-box {
display: inline-block;
width: 350px;
height: 200px;
/*border: 5px solid blue;*/
font-size: 0;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.69);
background-color: dodgerblue
}
.right-cell .content-box {
background-color: darkturquoise
}
.middle-cell {
height: 100%;
background-color: white;
width: 1.5px;
font-size: 0;
box-shadow: 0px 0px 10px black;
-moz-box-shadow: 0px 0px 10px black;
-webkit-box-shadow: 0px 0px 10px black;
}
.number-outer-container {
display: inline-block;
position: absolute;
}
.left-cell .number-outer-container {
/*margin-left:39px;*/
}
.number-inner-container {
height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
}
.number-banner {
width: 50px;
height: 50px;
background-color: crimson;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
}
.notch-outer-container {
display: inline-block;
}
.left-cell .notch-outer-container {
margin-right: 24px;
}
.right-cell .notch-outer-container {
margin-left: 10px;
}
.notch-inner-container {
height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
}
.notch {
width: 0;
height: 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
}
.left-face-notch {
border-right: 15px solid #520f23;
}
.right-face-notch {
border-left: 15px solid #571780;
}
<div class="wrapper">
<div class="cell left-cell" align="left">
<div class="step-container">
<div class="content-box"></div>
<div class="notch-outer-container">
<div class="notch-inner-container">
<div class="right-face-notch notch"></div>
</div>
</div>
<div class="number-outer-container">
<div class="number-inner-container">
<div class="number-banner"></div>
</div>
</div>
</div>
</div>
<div class="cell middle-cell"></div>
<div class="cell right-cell" align="right">
<div class="step-container">
<div class="number-outer-container">
<div class="number-inner-container">
<div class="number-banner"></div>
</div>
</div>
<div class="notch-outer-container">
<div class="notch-inner-container">
<div class="left-face-notch notch"></div>
</div>
</div>
<div class="content-box"></div>
</div>
</div>
</div>
In this SSCCE, inside .left-cell .step-container, I have three elements appearing on the same line: .content-box, .notch-outer-container, and .number-outer-container; and to make the .notch appear to be overlapping the right-cell by 50% of its width, I gave .number-outer-container a position:absolute; and .notch-outer-container a margin-right which pushes the number-outer-container to right side to an extent that it appears to be overlapping the (.middle-cell and) right-cell by 50% of it's width.
The problem is that in the .right-cell, this strategy is NOT working. First the .number-right-container appears and still it is absolute, I can not give it a left property with value relative to its parent (otherwise I would try a left:-25px to make it appear 25px behind the left edge of its parent, because it has width:50px;). Then the .notch is hidden below it...
So I am thinking about finding a way through which I can get the elements render from RTL (Right To Left) rather than LTR only inside .right-cell on the page. So that I can follow the same strategy I have used for the .left-cell, in the .right-cell.
There's numerous ways to achieve what you want using either flexing, floats or other options, but I'd say one of the easiest ways, if the rest of the layout works as you want it to, is to use the direction attribute.
div {
direction: rtl;
}
div div {
display: inline-block;
direction: ltr;
}
<div>
<div>first</div>
<div>second</div>
<div>last</div>
</div>
How do I give margin to an box respective to a floated box? Here's my source code:
<!DOCTYPE html>
<html>
<head>
<title>Boxes</title>
<link rel="stylesheet" type="text/css" href="intro.css">
</head>
<body>
<div id="page">
<div id="header">
<h3 class="welcome">Welcome</h3>
<h5 class="welcome">to</h5>
<h1 class="welcome" style="color:green;font-family:cursive">Tamim's</h1>
<h5 class="welcome">page</h5>
</div>
</div>
<div class="navigation">
<ul>
<li>home</li>
<li>photos</li>
<li>important-links</li>
<li>facebook</li>
</ul>
</div>
<div id="left">
<img src="408528_10200574301423959_1609852992_n.jpg">
</div>
<div id="right"></div>
<div id="test"></div>
</div>
</body>
</html>
and
#page{
min-width:360px;
margin: 10px auto 10px auto;
background-color: rgb(32,127,224);
padding: 20px;
border: 2px solid black;
box-shadow: inset 0px 0px 10px #777777;
border-radius: 5px;
}
#header{
width: 360px;
margin: 0px auto 0px auto;
text-align: center;
}
.welcome{
margin: auto;
text-align: center;
display: inline;
}
#left{
width: auto;
margin-top: 10px;
float: left;
border: 2px inset red;
padding: 10px;
border-radius: 5px;
background-color: rgb(157,160,146);
height: 425px;
}
#right{
float: right;
margin-top: 10px;
margin-left: 30px;
margin-right: 30px;
border: 2px solid green;
border-radius: 5px;
height: 425px;
width: 67%;
background-color: rgb(121,241,240);
}
.navigation{
padding: 1px 3px 3px 3px;
margin: 20px auto 20px auto;
width: 500px;
height: 40px;
background-color: red;
border-radius: 5px;
text-align: center;
}
.navigation li{
margin: 3px 6px 3px 6px;
display: inline;
border: 2px solid black;
padding: 2px;
zoom:1;
width:auto;
}
#test{
margin: 5px 5px 5px 5px;
height: 100px;
background-color: black;
clear: both;
border-radius: 5px;
}
Here's the code on Fiddle
Now when I give top a margin, it is not getting below the left or right? How do I give margin with respect to left? and also why my #lefts height is greater than right? But I have given them the same height 425px.?
Now when I give top a margin, it is not getting below the left or right?
Because you clear:both in the test - footer div. You have to set margin-bottom to the left and right see demo.
DEMO: http://jsfiddle.net/goodfriend/69QKz/14/
Why my #lefts height is greater than right?
It looks like it was caused by the padding in the left box.
DEMO with padding in left: http://jsfiddle.net/goodfriend/69QKz/6/
DEMO without padding in left: http://jsfiddle.net/goodfriend/69QKz/5/
Note: I also deleted one </div> end tag because it was closing the page div after the header..
How to center squares in the wrapper without using text-align:center?
I need this because it also centers all text in squares, but I don't need this.
HTML :
<div id="wrapper">
<div id="squares">
<div class="square">lol</div>
<div class="square">lol</div>
<div class="square">lol</div>
<div class="square">lol</div>
<div class="square">lol</div>
<div class="square">lol</div>
<div class="square">lol</div>
</div>
</div>
CSS:
html, body{
height: 100%;
}
body {
line-height: 18px;
}
#wrapper{
width: 960px;
height: 100%;
border: 1px solid red;
margin: 0 auto;
}
.square {
width:251px;
height:207px;
border: 1px solid #d6d6d6;
-webkit-box-shadow: 1px 1px 3px rgba(0,0,0,.1);
-moz-box-shadow: 1px 1px 3px rgba(0,0,0,.1);
box-shadow: 1px 1px 3px rgba(0,0,0,.1);
margin: 10px;
overflow:hidden;
position:relative;
background-color:#fff;
display: inline-block;
cursor: pointer;
}
#wrapper{
...
text-align: center;
}
.square {
...
text-align: left;
}
---- Another way (I don't recommed!)
How to find 52px: (width of div - (#of squares * width of one square))/ #of squares+1 ->
(960-(250*3))/4
#wrapper{
...
padding-left:52px;
}
.square {
...
margin: 10px 52px 10px 0;
}
You can try:
.squares {
margin-left:auto;
margin-right:auto;
}
Since it is text inside the squares you are styling you could put an H or P tag around the text and then text-align: left; them.
I found this image while searching the web and I tried to implement this display on my own. This is what I have so far:
My HTML code is here:
<ul>
<li>
<span style="display:block;"><a href="">
<span><img src="../creation/images/samps/unnamed4.png" width="48" align="absmiddle"/></span>
<span class="price" >Freeep</span>
<span class="appname">Name of the apps that is so long</span>
<span class="developer">by scamexdotexe</span>
</a>
</span>
</li>
</ul>
This is my CSS style:
<style type="text/css">
li{
list-style: none;
width:200px;
border:1px solid #00CCFF;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
padding: 0px;
}
li:hover{
border:1px solid red;
}
li a{
margin: 0px;
display: block;
width: 100%;
height: 100%;
white-space:nowrap;
text-overflow:ellipsis;
overflow:hidden;
text-decoration:none;
padding:2px;
}
li a span img{
padding: 5px;
}
.price{
position:absolute;
margin-top:4px;
margin-bottom:4px;
color:#0099FF;
font-size:12px;
}
.appname{
}
.developer{
font-size:12px;
color:#666666;
margin:0;
position:inherit;
display:inline;
white-space:nowrap;
}
</style>
I spent hours on cloning the display on the first image but it seems that I have no luck. Can you point what I am doing wrong here? What I really want to do is align the app name and the price horizontally and also align the app name, rating, total downloads vertically.
For starters, I'd change the border radius to 5px, and add a drop shadow:
li {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 0px 0px 5px #333;
-webkit-box-shadow: 0px 0px 5px #333;
box-shadow: 0px 0px 5px #333;
}
Do you want to use the same colors as well?
Here's a start for you: http://jsfiddle.net/k8ejp/4/
Notes:
the "avatar" div could of course be an image
absolute positioning can be used instead of floating if you want a more complex layout (or find it easier to work with position)
my example uses a few newer features of CSS (like text-overflow) but they should degrade without changing the layout.
HTML
<div class="box">
<div class="avatar">foo</div>
<div class="price">Free!</div>
<div class="name">A long app name A long app name A long app name A long app name</div>
<div class="info">Other info about the app goes here.</div>
</div>
CSS
.box{
font: 11px/1.5 sans-serif;
padding: 8px;
background-color: #ccddcc;
width: 400px;
border-radius: 4px;
border: 1px solid silver;
box-shadow: 2px 2px 2px #ddd;
}
.avatar {
width: 32px;
height: 32px;
background-color: #555;
float: left;
margin-right: 12px;
}
.price {
float: right;
color: green;
}
.name {
width: 200px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
I have created an example here: http://jsfiddle.net/D26Hj/1/.
It just needs an app logo and star sprite image.
I have drawn up a star sprite image and quickly made a fake logo in Paint.NET.
Info about the sprite:
Each star is 9px wide.
There are 5 stars in a rating, so therefore each rating is 45px wide.
Therefore, to change the rating change the background-position as per below.
Here are the background-positions to use for different star ratings:
-0px 0 Stars
-45px 1 Star
-90px 2 Stars
-135px 3 Stars
-180px 4 Stars
-225px 5 Stars
I have added classes to make it easier, use rating-0 to rating-5 for 0 stars to 5 stars.
HTML:
<div class="app">
<div class="image"></div>
<div class="title">
App title
</div>
<div class="price">$0.00</div>
<div class="rating rating-3">3 stars</div>
<div class="info">1024 downloads</div>
</div>
CSS:
body {
padding: 20px;
}
.app {
position: relative;
width: 225px;
height: 50px;
padding: 5px;
background: #8f8;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
border: 1px solid #484;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0 0 2px #484;
-moz-box-shadow: 0 0 3px #888;
-webkit-box-shadow: 0 0 3px #888;
}
.app a {
text-decoration: none
}
.app .image, .app .title, .app .price, .app .rating, .app .info {
position: absolute;
}
.app .image {
left: 5px;
top: 5px;
width: 48px;
height: 48px;
background-image: url('http://i.imgur.com/JAgto.png');
}
.app .title {
left: 60px;
top: 7px;
}
.app .price {
right: 5px;
top: 7px;
color: #262;
}
.app .rating {
left: 65px;
top: 25px;
width: 45px;
height: 10px;
text-indent: -999px;
background-image: url('http://i.imgur.com/giWyQ.png');
background-position: -135px 0;
}
.app .info {
left: 60px;
top: 40px;
font-size: 11px;
color: #666;
}
.rating-0 {
background-position: 0 0;
}
.rating-1 {
background-position: -45px 0;
}
.rating-2 {
background-position: -90px 0;
}
.rating-3 {
background-position: -135px 0;
}
.rating-4 {
background-position: -180px 0;
}
.rating-5 {
background-position: -225px 0;
}
I'm not so sure you should use span, personally I would use div instead since it's default display style is already block, which I see is what you try to achieve on the description block.
And about the Price and AppName, I would suggest that you wrap them inside a Div container on the same level with rating and downloads count and make that container display style inline-block then adjust the width for both Price and AppName.
It would be like this
<div class="main-container">
<div class="image"> Image Goes Here </div>
<div class="description">
<div class="description-top">
<div class"description-top-title"> Title Goes Here</div>
<div class"description-top-price"> Price Goes Here</div>
</div>
<div class="description-middle"> Rating Goes Here</div>
<div class="description-bottom"> Download Count Goes Here</div>
</div>
</div>
.main-container{
display: inline-block;
}
.image{
width: 30%;
}
.description{
display: block;
width: 70%;
}
.description-top{
display: inline-block;
}
.description-top-title{
width: 60%;
}
.description-top-price{
width: 40%;
}