I want to create a photo gallery for one of my projets but I can't achieve it. What I want is something like that :
I don't know how many photo there will be but basically what it does is:
- Insert first photo in photo_div #1
- Insert 2nd in #2
- Goes to new line
- Insert 3rd in #3
- Insert 4th in #4
- Go to next column and first line
- Insert 5th in #5
- etc.
What I've made so far is the following code :
<div id="scroll_container">
<div id="photo_0" class="div_photo">
<!-- More content inside -->
</div>
</div>
And the CSS code :
scroll_container{
height:100%;
width:550px;
overflow-x:scroll;
overflow-y:hidden;
}
.div_photo{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
But all I can achieve is a two columns gallery with 3 lines.
Could you help me to solve that ?
Thanks
Looks like your images are always of the same size, and that your problem is just the special order that you want.
In that case, this could be a solution:
.test {
width: 40px;
height: 40px;
border: solid 1px blue;
float: left;
margin: 2px;
}
.test:nth-child(4n+3)
{
border-color: red;
position: relative;
top: 44px;
left: -92px;
margin-right: -44px;
}
.test:nth-child(4n+4)
{
border-color: red;
position: relative;
top: 44px;
left: -46px;
margin-right: -44px;
}
fiddle
The idea is to float the first 2 elements, the 5 and 6, and so on. the 3rd and 4th (and 7th and 8th) are positioned relative to take them to the special positions
CSS
.div_photo{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
.div_photo_1{
float:left;
width:250px;
height:250px;
border:1px solid black;
margin:0 5px 5px 0;
position:relative;
display:inline-block;
}
#scroll_container_1 {
height:auto;
width:257px;
display:inline-block;
}
#scroll_container {
height:auto;
width:514px;
}
#scroll_container_parent {
height:auto;
width:771px;
overflow-x:scroll;
overflow-y:hidden;
}
HTML
<div id="scroll_container_parent">
<div id="scroll_container">
<div id="photo_1" class="div_photo">1</div>
<div id="photo_2" class="div_photo">2</div>
<div id="photo_3" class="div_photo">3</div>
<div id="photo_4" class="div_photo">4</div>
<div id="photo_6" class="div_photo">6</div>
<div id="photo_7" class="div_photo">7</div>
<div id="photo_9" class="div_photo">9</div>
<div id="photo_10" class="div_photo">10</div>
</div>
<div id="scroll_container_1">
<div id="photo_5" class="div_photo_1">5</div>
<div id="photo_8" class="div_photo_1">8</div>
<div id="photo_11" class="div_photo_1">11</div>
</div>
</div>
Modified HTML...may be this should be good
This way you can write your html:
<div id="scroll_container">
<div id="photo_1" class="div_photo">
<!-- More content inside -->1
</div>
<div id="photo_2" class="div_photo">
<!-- More content inside -->2
</div> <div id="photo_3" class="div_photo">
<!-- More content inside -->3
</div> <div id="photo_4" class="div_photo">
<!-- More content inside -->4
</div> <div id="photo_5" class="div_photo">
<!-- More content inside -->5
</div>
</div>
For the 5th one you can apply additional css with id as :
#photo_5 {
display:inline-block;
margin-left:520px;
margin-top:-510px;
}
As you don't want to use table then you can achieve this with css.
Working Fiddle : jsFiddle Working Demo
Related
I want to insert a little green square between words on my WordPress homepage. I wrote the html:
<div class="x"><center><p
style="border:10px; border.
style:solid;
border-color:#00ff00; padding:
0.0em; width: 2px; height:
2px;">
</p></center></div>
Pen: https://codepen.io/adsler/pen/KOXzPw
Site: http://4309.co.uk
Every other page I can access and edit but not the same for homepage.
Here you go.
go to your appearance, customise, add'text widget' then add the html code. If you were to add the css, you would need to go to --> appearance --> additional css
Have a great day!
Austin
It will be work
<div class="x"><center><p >Write Something<span style="border:10px; border-style:solid; border-color:#00ff00; padding: 0.0em; width: 2px; height: 2px;"></span> New</p></center></div>
Pen: https://codepen.io/shakil-shaikh/pen/xvXdEX
3 divs. Div one for top, div two for the square, and div three for bottom. If you need more explanation, I can elaborate.
Check below.
Box ‘one’ would be where text one goes, ‘center’ is where you would style the geometric shape, and ‘box2’ is where the second string of text will go.
When I get to my computer I’ll see if I can write out the full code for you to use.
<div id=box1></>
<div id=center></>
<div id=box2></>
Is this what you want to accomplish?
<!doctype html>
<head>
<meta char="utf-8">
<title>box test</title>
<style>
#content {
margin:25px auto;
}
#text-1 {
border:#000000 2px solid;
width:20%;
height:20%;
margin-bottom:10px;
}
#shape {
border:#000000 2px solid;
width:20%;
height:20%;
}
#text-3 {
border:#000000 2px solid;
width:20%;
height:20%;
margin-top:10px;
}
</style>
</head>
<body>
<div id=content>
<div id=text-1>text one</div>
<div id=shape>shape</div>
<div id=text-3>text two</div>
</div>
</body>
<html>
Does this work? the position property allows you to put your div's anywhere on the website. Just remember that the attribute allows for stacking. Just use the left/right/top/bottom attribute.
#container {
width:1000px;
}
#x {
position:absolute;
top:0px;
left:0px;
background-color:blue;
}
#center {
position:absolute;
top:0px;
left:150px;
}
#y {
position:absolute;
top:0px;
left:300px;
background-color:#ffff00;
}
<div id="container">
<div id="x">Write something</div>
<div id="center">middle</div>
<div id="y">New</div>
</div>
I have been constructing UI development for a year now and I want to explore new structures in regards to designing.
so I am styling my panel-heading that it would look something like this.
as of now I have only done the default style for panel heading via bootstrap css.
I just posted an example to how can make it with position. if you don't need then check 2nd snippet
.main {
position:relative;
}
.tilt {
position:absolute;
top:30px;
left:0px;
transform:rotate(-90deg);
color:#000;
padding:0 10px;
border:1px solid #000;
text-align:center;
}
.tilt p {
margin:0px;
}
<div class="main">
<div class="tilt">
<p>
HELLO
</p>
</div>
</div>
.tilt {
transform:rotate(-90deg);
color#000;
padding:0 10px;
border:1px solid #000;
text-align:center;
display:inline-block;
margin-top:22px;
}
.tilt p {
margin:0px;
}
<div class="tilt">
<p>
HELLO
</p>
</div>
I am making a CSS design for a SIM game I play, and a customer asked for 4 boxes, two large and in between them, two horizontally aligned boxes. They work fine, unless I try and add headers. The entire website is set up in a ridiculous amount of tables, basically coding from the 90s. All boxes I have made are div and aligned to meet up with the existing boxes on the page.
The main boxes are how I want the headers on all four boxes, separate and do not scroll. However, as you can see from this fiddle, nothing is aligning. When I try to put headers on the horizontal boxes, it really messes up the align. I am a fairly new coder, and would greatly appreciate some help.
div {
display: block;
color: #fff;
}
.topcontain{
width:500px;
height:300px;
}
.topleftbox {
width:240px;
height:300px;
overflow:auto;
float:left;
background:#505665;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
font-size: 12px!important;
margin: 5px;
opacity: .75;
}
.toprightbox {
width:240px;
height:300px;
overflow:auto;
float:right;
background:#505665;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
font-size: 12px!important;
margin: 5px;
opacity: .75;
}
.bottomcontain {
width:500px;
height:300px;
}
.header {
width:500px;
float:center;
background:#060e23;
color:#fff;
text-align:center;
display:block;
font-size: 14px;
border: 1px solid #030711;
opacity: 1.0;
}
.bottombox {
width:500px;
height:300px;
overflow:auto;
float:center;
background:#505665;
font-size: 12px;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
opacity: .75;
}
.credit {
width:500px;
float:center;
background:#060e23;
color:#fff;
text-align:center;
display:block;
font-size: 12px;
border: 1px solid #030711;
opacity: .85;
}
.top {
font-family: 'Snippet', sans-serif;
background : #060e23;
color : #fff;
font-size : 15px;
padding : 5px 15px;
font-weight : normal;
text-align : center;
border: 1px solid #030711;
opacity: .90;
}
Here is how it looks on the page I am coding:
example
Thank you again!
http://jsfiddle.net/6bEsE/6/
<div class="bottomcontain">
<div class="header">Lorem ipsum</div>
<div class="bottombox">
[TOP]
</div>
</div>
<div class="topcontain">
<div class="topleftbox">
<div class="top">Lorem ipsum</div>
<div>
[MIDDLE LEFT]
</div>
</div>
<div class="toprightbox">
<div class="top">Lorem ipsum</div>
<div>
[MIDDLE RIGHT]
</div>
</div>
</div>
<div class="bottomcontain">
<div class="header">Lorem ipsum</div>
<div class="bottombox">
[BOTTOM]
</div>
</div>
<div class="credit">Layout and CSS by Echo [#15480]</div>
I did a fast clean of your code (5 minutes)
But it is far from finishing it
First of all, you have bad closing of divs.
Second, you have fixed height for divs. A div with fixed width and height and more text than can fit in it will create scrolls.
before inserting all that text, try to fix the containers starting from the simple example i provided above. Also you may need to change a bit the html structure, to group those floating middle divs.
Demo Fiddle
In CSS
.clear{
clear:both;
}
In HTML
<div class="clear"> </div>
I'm trying to align a button and some text at the bottom of a div much like the example below with the Price and the Check it out button. What's the best way to do this. I've made a div, styled it to get the text, and picture right. I just need to attach the button to the right-hand side and the price to the left, inline with each other.
Similar to the product displays in the website thisiswhyimbroke.com
http://www.thisiswhyimbroke.com/
^^ Price and the Check It Out button. How do I achieve this?
Try like this: DEMO
Try to use reset you CSS first.
CSS:
*{
padding:0;
margin:0;
}
#priceAndButton {
width:100%;
display:block;
height:30px;
line-height:30px;
}
#priceAndButton h4 {
float:left;
vertical-align:middle;
}
#priceAndButton img {
float:right;
}
Hope this helps you
I have created a working fiddle with your requirements:
http://jsfiddle.net/8993H/
HTML:
<div id="main-container">
<div class="img-div"><img src="http://tiwibzone.tiwib.netdna-cdn.com/images/beer-chug-flowmeter1-300x250.jpg"/></div>
<div class="rhs">
<div class="button-nav">
<span class="price">$35.00</span>
<span class="check-btn"><button>Check It Out</button></span>
</div>
</div>
</div>
CSS:
#main-container{
width:100%;
border: 1px solid #aaa;
}
.img-div{
width:50%
}
.img-div img{
width:100%;
}
.rhs{
width:48%;
float:right;
position:relative;
}
.button-nav{
position:absolute;
bottom:10px;
width:100%;
}
.price{
float:left;
}
.check-btn{
float:right;
}
Try this:
button{
float:right
}
#price{
float:left
}
Here i created one working fiddle for your requirement.. You can re use this CSS. Hope This will help you.
HTML
<div class="desc">
<img height="200px" width="200px" src="http://www.clker.com/cliparts/8/2/2/6/11971154711712468971BigRedSmile_A_screwdriver_1.svg.med.png"/>
<p>Move over sliced bread, the water jet pack is officially the greatest thing ever. For only sixty eight grand you can own your very own water thrusting jetpack. It can lift you up to 30 feet high and thrust forward at 30 miles per hour – practically guaranteeing certain death.</p>
<div class="button">
Check it out
</div>
<div class="price">$500.00</div>
</div>
CSS
.desc{
text-align:jstify;
width:50%;
}
.button a{
background-color: #faab37;
color: white;
display: block;
float: right;
padding: 7px 8px;
text-decoration: none;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1);
}
.button a:hover{
background-color:#f9bd66;
}
Hope This is What your expected output
I'm building a website for a client to produce a comic strip. There are five divs for panels:
Right square
Left square
Right tall (double height)
Left tall(double height)
Double wide
I'm trying to provide a solution to teach them to fish as opposed to giving them fish.
Here's my problem:
index.html
If you go to the bottom of the 'template' div (has the comic panels), you'll see that the bottom set is not right. It should mirror the second set, so instead of a tall on the left and two squares on the right, I want two squares on the left and the tall on the right. I've tried a couple of things to no avail. Here's what I've got as far as code:
CSS:
.panel_square_l
{
position:relative;
float:left;
width:350px;
height:350px;
border: 1px solid black;
margin:5px 5px 5px 0;
clear:none;
}
.panel_square_r
{
position:relative;
float:left;
width:350px;
height:350px;
border: 1px solid black;
margin:5px 0 5px 5px;
clear:none;
}
.panel_wide
{
position:relative;
float:left;
width:712px;
height:350px;
border: 1px solid black;
margin:5px 0 5px 0;
clear:none;
}
.panel_tall_l
{
position:relative;
float:left;
width:350px;
height:712px;
border: 1px solid black;
margin:5px 5px 5px 0;
clear:none;
}
.panel_tall_r
{
position:relative;
float:left;
width:350px;
height:712px;
border: 1px solid black;
margin:5px 0 5px 5px;
clear:none;
}
.template
{
position:relative;
float:left;
width:714px;
height:auto;
padding:17px;
border: 1px solid black;
}
HTML:
<!--Start Build Comic-->
<div class="title">
Title, Episode, Author, etc.
</div>
<div class="date">
Date
</div>
<div class="panel_square_l">
</div>
<div class="panel_square_r">
</div>
<div class="panel_tall_l">
</div>
<div class="panel_square_r">
</div>
<div class="panel_square_r">
</div>
<div class="panel_wide">
</div>
<div class="panel_square_l">
</div>
<div class="panel_square_l">
</div>
<div class="panel_tall_r">
</div>
<!--End Build Comic-->
You're trying to do a grid layout. Check this article for tips. http://www.smashingmagazine.com/2007/04/14/designing-with-grid-based-approach/
What I ended up doing was to create blocks of divs that act as one (a panel that is one panel height high and two panel widths across), two (side-by-side panels that are each one high and one across,)or three (one panel that is two panels high next to two panels over/under) comic panels. This gives the strip writer the ability to customize the layout of each strip they make.
You can check it out here
Go through some of the Archives to see the different layouts.