div inside a div vertical in a side bar using css - html

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

Related

Can't move elements in css divs

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

Prevent float right sections overlap the wrapper

I have every other section floated a different direction but the sections that are floated right overlap the wrapper. How do I get it to not do that?
Also, I tried incorporating the float into the nth-child (odd/even) of the css and I couldn't get it to work right. If someone can help me do that so I can get rid of the float classes I would be grateful.
http://codepen.io/anon/pen/bdoQPQ
body,
html {
font: 1em "Open Sans", sans-serif;
margin: 0px;
padding: 0px;
}
#wrapper {
padding: 0px 10px 0px 10px;
width: 100%;
}
.vertSection {
width: 75%;
height: 175px;
border-top: 1px solid black;
border-bottom: 1px solid black;
margin: 0px 0px 15px 0px;
padding: 5px 0px 0px 10px;
box-shadow: 0px 3px 5px #888, 0px -3px 5px #888;
display: inline-block;
}
.vertSection:nth-child(even) {
float: left;
}
.vertSection:nth-child(odd) {
float: right;
text-align: right;
}
.vertSection p {
text-align: left;
}
.vertSection img {
line-height: 75px;
}
.floatL {
float: left;
}
.floatR {
float: right;
}
.clear {
clear: both;
}
<section id="wrapper">
<section>
<h1>Header</h1>
<p>This is where some information on my services would go.</p>
</section>
<section class="vertSection">
<img src="images/html5css3.png" class="floatL">
<h2>Heading</h2>
<p>A bunch of text and description here!</p>
</section>
<section class="vertSection">
<img src="images/responsive.png" class="floatR">
<h2>Heading</h2>
<p>A bunch of text and description here!</p>
</section>
<section class="vertSection">
<img src="images/search.jpg" class="floatL">
<h2>Heading</h2>
<p>A bunch of text and description here!</p>
</section>
<section class="vertSection">
<img src="images/communicate.png" class="floatR">
<h2>Heading</h2>
<p>A bunch of text and description here!.</p>
</section>
</section class="">
The problem is likely related to this part.
#wrapper {
padding: 0px 10px 0px 10px; /*top right bottom left*/
width: 100%;
}
So 100% + 10px + 10px causes the overflow, remove width:100% it should all good. By the way, it's safer to also set section {display:block;} in case some browsers don't render it as block level element.

moving GridView to the center of the div

i know this question has been asked before. i have tried it all but nothing seems to be working.
this is my HTML and CSS code..
body {
color: #666;
font: 12px/17px Arial,Helvetica,sans-serif;
background: -moz-linear-gradient(center top , #C9D3DF 0%, #FFF 100%) no-repeat scroll 0% 0% transparent !important;
}
#container{
width:1349px;
height:auto;
}
#wrapper{
width:940px;
height:auto;
margin: 0px auto 0px auto;
padding: 0px;
position: static;
box-shadow:2px 2px 5px 5px #888888;
-webkit-box-shadow: 2px 2px 5px 5px #888888;
-moz-box-shadow: 2px 2px 5px 5px #888888;
background-color: #FFFFFF;
border-radius: 8px;
}
#header {
margin: 0px auto 0px auto;
padding: 0px;
position: static;
width: 940px;
height: 169px;
}
#contentholder {
width:940px;
height:111px;
padding:0px;
margin:0px;
}
#logo {
margin:14px 0px 0px;
height:67px;
width:397px;
padding:0px;
float:left;
overflow:hidden;
}
#linkholder {
height:31px;
width:323px;
float:right;
overflow: hidden;
margin: 0px 0px 2px;
padding:5px;
}
#links {
float: right;
font-size:small;
height: 0px;
padding-right:7px;
padding-top:3px;
width: 176px;
}
#links li {
margin: 0px 0px 0px 9px;
float: left;
height: 26px;
display: inline;
padding-right:15px;
color:blue;
padding:3px;
border-radius:10px;
box-shadow: 1px 1px 2px 2px #888888;
text-align:center;
}
#menu {
width:940px;
height:45px;
font-size: 16px;
font-weight: bold;
text-align: center;
background-color: #0000FF;
color: #FFFFFF;
border-radius: 8px;
}
#menu ul {
height: 31px;
padding: 15px 0px 0px 0px;
margin: 0px;
overflow:hidden;
}
#menu li {
display: inline;
padding: 20px;
text-align:center;
}
#image{
width: 940px;
height: 250px;
margin: 0px auto 0px auto;
padding: 0px;
position: static;
background-color: #0000FF;
}
#image img {
width:100%;
height:100%;
}
#mbody {
height:auto;
width:940px;
margin: 0px auto 0px auto;
padding: 0px;
position: static;
}
#mbody h1 {
text-align:center;
}
#text{
width:800px;
margin: 0px auto 0px auto;
text-align:justify;
padding: 0px 20px 0px 20px;
}
#footer {
width: 940px;
height:60px;
margin: 0px auto;
overflow: hidden;
}
#copyrt {
text-align:center;
color:gray;
padding-top:20px;
}
#mission {
width:46%;
text-align:justify;
float: left;
}
#mission h2 {
text-align:center;
}
#vision {
width:41%;
text-align:justify;
float: right;
}
#vision h2 {
text-align:center;
}
.gview {
height: 100px;
width:200px;
margin-left: auto; margin-right: auto;
box-shadow: 1px 2px 1px 2px #888888;
position:relative;
}
</head>
<body>
<form id="form1" runat="server">
<!-- header placement -->
<div id="container">
<div id="wrapper">
<header id="header">
<div id="contentholder">
<span id="logo">
<img src="Images/logo.png" /></span>
<div id="linkholder">
<ul id="links">
<li>Admin Login</li>
<li>Register</li>
</ul>
</div>
</div>
<!--Menu creation-->
<nav id="menu">
<ul>
<li>Home</li>
<li>Patient Care</li>
<li>Doctors</li>
<li>Appointments</li>
<li>Departments</li>
<li>Blood Bank</li>
<li>About Us</li>
</ul>
</nav>
</header>
<!-- Main image -->
<div id="image">
<img src="/Images/cardio.jpg" alt="Cardiology" />
</div>
<!--Main content-->
<div id="mbody">
<div id="text">
<h1>Department of Cardiology</h1>
<p>
Cardiovascular diseases are the main factor of death in the Western World, and they represent a challenge for diagnosis, treatment and research. Sigma Medicare is always prepared
to provide patients with the most accurate diagnosis and professional manner of treatment. Our doctors are dedicated to your health. In addition to quality care,
our department is also involved in teaching and numerous researches.
</p>
<div class="gview">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CID" DataSourceID="SqlDataSource1" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
<Columns>
<asp:BoundField DataField="CID" HeaderText="CID" InsertVisible="False" ReadOnly="True" SortExpression="CID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
<asp:BoundField DataField="Qualification" HeaderText="Qualification" SortExpression="Qualification" />
<asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" />
<asp:BoundField DataField="Appointment_Timings" HeaderText="Appointment_Timings" SortExpression="Appointment_Timings" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:masterConnectionString %>" SelectCommand="SELECT * FROM [Cardiology]"></asp:SqlDataSource>
</div>
</div>
</div>
<!--Footer Content-->
<footer id="footer">
<p id="copyrt">Copyright &copy 2015, by Sigma Medicare. All rights reserved.</p>
</footer>
</div>
</div>
</form>
</body>
Please note that container DIV is 800px. any kind of help will be greatly appreciated. I have tried everything that has been suggested before but nothing seems to be working.
Thanks.
Edit: #Lal: Entered whole code for the page and CSS..
You have no problem with the CSS, its correct. Actually the div is center aligned. I've edited the snippet in your question Itself. See it..
The problem is with the GridView. I think you have some CSS overriding the styles applied for the gview. So kindly check the styles applied for your GridView.

How to align with css

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
}

How to vertically align several images css?

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;
}