For some reason I have a parent div called banner which contains a number of child divs, however in my css styles sheet I can't seem to move any elements especially the "CRAFT412" logo image to my desired position within the banner. I've tried using left/right/top/bottom to move these elements but nothing seems to budge them. If anyone could help me here I'd appreciative it.
Here is my HTML for a page on my site
<!--TOP BANNER SECTION-->
<div id="banner">
<div id="logo">
<img src="images/CRAFT412 - Logo.png" width="500" height="281" alt="CRAFT412">
</div>
<div id="ip_box"></div>
<div id="ip_text">
<p>SERVER IP<P/>
<p>craft412.serveminecraft.net<P/>
</div>
<div id="teamspeak_box"></div>
<div id="teamspeak_box_2"></div>
<div id="teamspeak_text">
<p>TEAMSPEAK<P/>
</div>
<div id="teamspeak_image">
<a href="ts3server://craft412.serveminecraft.net:9987">
<img src="images/CRAFT412 - Box - Teamspeak.png" alt="TEAMSPEAK">
</a>
</div>
</div>
Also here is my CSS for the same divs
/*CSS FOR ALL PAGES*/
/*BODY/WRAPPER SECTION*/
body {
background:#EEEEEE;
background-repeat: no-repeat;
background-attachment: fixed;
}
#wrapper {
width: 1750px;
margin: 0 auto;
background-color: white;
border-radius: 5px;
box-shadow: 0px 1.5px 2px 0px;
border: 1.5px solid #E0E0E0;
color: #E0E0E0;
}
/*TOP BANNER SECTION*/
#banner { height:100px; }
#logo {}
#ip_box {
width:200px;
height:43px;
background:#212121;
border-radius: 5px;
box-shadow: 1px 1px 5px;}
#ip_text {
color: white;
font-size: 15px;
}
#teamspeak_box {
width:159px;
height:43px;
background:#212121;
border-radius: 5px;
box-shadow: 1px 1px 5px;
}
#teamspeak_box_2 {
width:43px;
height:43px;
background:#313131;
border-radius: 5px 0px 0px 5px;
}
#teamspeak_text { color: white; }
#teamspeak_image {}
Give the parent div a property :
Position:relative;
Also give the property to child div:
Position:absolute;
Now you can change the places of child div inside the "BANNER" div. by using TOP , BOTTOM, RIGHT, LEFT
Related
I want to display my subtitles with unique style. So we use the following css code for style
.title-1 {
border-bottom: 1px solid #4db2ec;
margin-bottom: 10px;
padding-bottom: 4px;
position: relative;
font-size: 16px !important;
color: #FFF }
.title-1 > span {
background: #4db2ec;
width: auto;
padding: 4px 7px }
Now I am insert advertisement block with following html code with wrap text.
<div style="float: right; margin-left: 20px;">
<img src="http://domain.com/ad.jpg" height="600" width="160">
</div>
<h2 class="title-1"><span id="location">My Sub Title</span></h2>
now my title style is operlap in my advertisement block. how to solve this?
Here is a jsFiddle: http://jsfiddle.net/f025d5Lh/
Simplest is to add z-index:-999; to .title-1, this will push down the relative div below any div
Demo
CSS
.title-1 {
border-bottom:1px solid #4db2ec;
margin-bottom:10px;
padding-bottom:4px;
position:relative;
font-size:16px !important;
z-index:-999; /* only change */
color:#FFF
}
.title-1 > span {
background:#4db2ec;
width:auto;
padding:4px 7px
}
I have a Bootstrap .hero-unit box, and then I have a Fork me on Github ribbon that I am displaying in the top left corner of this box.
Usually a ribbon is placed in a corner of the screen, but in the case it isn't. So how do I hide the part of the ribbon that overflows its parent element?
The HTML:
<div class="hero-unit my-unit">
<a class="ribbon" href="#">Fork me on Github</a>
</div>
</div>
The CSS for the parent element:
.my-unit {
border-radius: 10px;
border: 1px solid #cfcece;
}
The CSS for the ribbon:
.ribbon {
position:absolute;
padding:5px 45px;
width:128px;
background-color:#555451;
color:#e5e5e5;
font-size:13px;
font-family:sans-serif;
text-decoration:none;
font-weight:bold;
-webkit-backface-visibility:hidden;
letter-spacing: .5px;
border:2px dotted #e5e5e5;
box-shadow:0 0 0 3px #383733,0 0 20px -3px rgba(0,0,0,.5);
text-shadow:0 0 0 #e5e5e5,0 0 5px rgba(0,0,0,.3);
margin-top:10px;
margin-left:-80px;
-ms-transform:rotate(330deg);
-moz-transform:rotate(330deg);
-webkit-transform:rotate(330deg);
transform: rotate(330deg);
}
Your HTML should be
<div class="container">
<div class="hero-unit my-unit">
<img class="ribbon"src="https://camo.githubusercontent.com/82b228a3648bf44fc1163ef44c62fcc60081495e/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png">
</div>
</div>
Your CSS should be
.ribbon{
top: 0;
left: 0;
border: 0;
}
Demo : http://jsbin.com/piqinore/2/
Did you check the official github page to incorporate this ribbon , check it out at
https://github.com/blog/273-github-ribbons
I have three images all in a box. How can I align them in css so that there is an even amount of space between them, as well as the top and bottom borders of the box?
At the moment my code looks something like this:
<div id="topRight">
<img src="image1.jpg" width="300px">
<img src="image2.jpg" width="300px">
<img src="image3.jpg" width="300px">
</div>
And the css:
#topRight {
float: right;
margin-top: 200px;
width: 300px;
height: 630px;
padding-top: 10px;
background-color: white;
padding-left: 10px;
padding-right: 10px;
box-shadow: rgba(0,0,0,0) 0px 2px 3px, inset rgba(0,0,0,0) 0px -1px 2px;
border-radius: 20px;
border: 1px solid #00BFFF;
}
set height to 100% so the border will will be at the end of the images.
include this code into style :
img {
margin: 0px auto;
}
or
img {
margin: 10px;
position :relative;
display: block;
}
You can vertically display images using <ul>...</ul>
Each image is put into an <li> tag !
<ul id="topRight">
<li><img src="image1.jpg" width="100px"></li>
<li><img src="image2.jpg" width="100px"></li>
<li><img src="image3.jpg" width="100px"></li>
</ul>
Then the bullets are removed using list-style:none;
margin:value 0; can be used to provide equal spacing.
Now Additional Equal spacing can be added using padding:value;
For Vertical Spacing alone use padding:value 0;;
WORKING DEMO -> CLICK HERE
jsFiddle
#topRight {
padding-top:10px;
padding-left:10px;
padding-right:10px;
width: 300px;
height: 100%;
background-color: white;
box-shadow: rgba(0,0,0,0) 0px 2px 3px, inset rgba(0,0,0,0) 0px -1px 2px;
border-radius: 20px;
border: 1px solid #00BFFF;
}
img {
padding-bottom:10px;
vertical-align:top;
}
I'm creating a box containing some image links, and currently I've got something that looks great on Chrome and Safari, but wraps at Firefox's default zoom level. Zooming in makes the box look fine, but at the normal zoom level they're wrapped. Here's what it looks like normally, on Chrome:
...and this is how it looks on Firefox:
The strange thing about this is that the right box isn't completely wrapped: some of the top and bottom borders are visible on the first line and I can't make sense of why it is wrapped at this particular point. This is what the HTML looks like:
<div class="clearfix buyTrackContainer">
<div class="buyTrackBox">
<p>Buy this Track</p>
<div class="buyLinksBox">
<div class="buyLinksBoxLeft">
<div class="d-itunes"></div>
</div>
<div class="buyLinksBoxRight">
<div class="d-amazon"></div>
</div>
</div>
</div>
<div class="buyTrackBox">
<p>Buy on Vinyl/CD</p>
<div class="buyLinksBox">
<div class="buyLinksBoxLeft">
<div class="b-ebay"></div>
</div>
<div class="buyLinksBoxRight">
<div class="b-amazon"></div>
</div>
</div>
</div>
...and the relevant CSS is as follows:
.buyTrackContainer {
text-align: center;
}
.buyTrackBox {
display:inline-block;
border:1px solid #ddd;
padding-left: 3px;
padding-right: 3px;
padding-top: 1px;
padding-bottom: 5px;
width:46%;
text-align:left;
background-color: #fff;
border-radius: 3px;
border-bottom:3px solid #ddd;
}
.buyLinksBoxLeft {
display:inline;
border: 1px solid #ddd;
border-bottom: 3px solid #ddd;
border-radius: 3px 0px 0px 3px;
padding: 12px 4px 8px 8px;
text-align:center;
vertical-align:center;
background-color:#fff;
}
.buyLinksBoxRight {
display:inline;
border: 1px solid #ddd;
border-bottom: 3px solid #ddd;
border-radius: 0px 3px 3px 0px;
border-left:0px;
padding: 12px 8px 8px 4px;
text-align:center;
vertical-align:center;
background-color:#fff;
}
.buyLinksBox {
display:block;
text-align:center;
padding-bottom:10px;
padding-top:8px;
}
div.d-itunes {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/iTunes-buy-button.png) no-repeat;
}
div.d-amazon {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/Amazon-buy-button.png) no-repeat;
}
div.b-ebay {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/eBay-buy-button.png) no-repeat;
}
I'm relatively new to proper CSS design so I'd appreciate any pointers about how I could improve my coding style. Does anyone know what might be happening here that could cause this?
Ill try with the first container change the add the following to
.buyTrackBox {
white-space:nowrap
}
.buyLinksBoxLeft {
float:left;
}
.buyLinksBoxRight {
float:right;
}
More over try dividing the width of buyLinksBoxLeft and buyLinksBoxRight in percentages so as to fit th parent container some thing around 40% may do. do the same with the buyLinksBox div and children
on your class, 'buyLinksBoxLeft' & 'buyLinksBoxRight' change
display: inline;
to
display: inline-block;
fiddle: http://jsfiddle.net/aqAVy/
That should sort it out.
Avoid redundancy in names... eg. change .BuyLinksBoxRight (son of .BuyLinksBox) to just .right (same with .left)
When multiple items has a lot of common properties, group them in a common selector.
Use oneliner paddings and borders when you can.
Code will be more readable and problems will vanish.
Running Demo
.buyTrackContainer {
text-align : center;
}
.buyTrackContainer > div,
.buyLinksBox > div {
display : inline-block;
border : 1px solid #ddd;
}
.buyTrackBox {
background-color : #fff;
border-bottom : 3px solid #ddd;
border-radius : 3px;
text-align : left;
padding : 1px 3px 5px 3px;
width : 134px;
}
.buyLinksBox {
padding-bottom : 10px;
padding-top : 8px;
text-align : center;
}
.buyLinksBox > div {
background-color : #fff;
vertical-align : center;
border-bottom : 3px solid #ddd;
text-align : center;
}
.buyLinksBox > .left {
border-radius : 3px 0px 0px 3px;
padding : 12px 4px 8px 8px;
}
.buyLinksBox > .right {
border-radius : 0px 3px 3px 0px;
border-left : 0px;
padding : 12px 8px 8px 4px;
}
.buyLinksBox > div > a > div {
margin-left : 0px;
height : 17px;
width : 50px;
}
div.d-amazon, div.b-amazon {
background : url(/images/misc/Amazon-buy-button.png) no-repeat;
}
div.d-itunes {
background : url(/images/misc/iTunes-buy-button.png) no-repeat;
}
div.b-ebay {
background : url(/images/misc/eBay-buy-button.png) no-repeat;
}
i have a page that i need to have a left side bar that this one contain a a title under that an image under that a text under that a list how can i do this i tried the relative position and absolute but it did not work
what i need is a div inside a div means the leftsidebar is a div that include the the title , image, text, list.
can anyone help me ?????
this what i tried to do to the image
.leftsideBar h2 {
padding: 0px 0px 30px 0px;
letter-spacing: -1px;
font-size: 2em;
}
.leftsideBar {
float: left;
width: 290px;
padding: 0px 0px 20px 0px;
border:5px solid #FF0000;
position:relative;
}
#profileImage{
position:absolute;
top:40px;
border:5px solid #0000FF;
}
Is this fiddle what you are trying to achieve?
html:
<div class="leftsideBar">
<h2>title</h2>
<img src="" height="100" width="100"/>
<ul>
<li>test1</li>
<li>test1</li>
<li>test1</li>
<li>test1</li>
</ul>
</div>
css:
.leftsideBar h2 {
padding: 0px 0px 30px 0px;
letter-spacing: -1px;
font-size: 2em;
}
.leftsideBar {
float: left;
width: 290px;
padding: 0px 0px 20px 0px;
border:5px solid #FF0000;
position:relative;
}
#profileImage{
border:5px solid #0000FF;
}
here it is another option with the text next to the image -> fiddle2