Jump to content

[SOLVED] Why oh why css?


ngreenwood6

Recommended Posts

I have a css file:

 

body {
margin:0 auto;
width:800px;
height:100%;
border:1px solid #000000;
}
#input {

}
#get {

}

#time {
float:right;
}

 

Then I have an html file:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script type="text/javascript" src="get.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="input">
<form name="form1">
Keyword:
<input type="text" name="keyword" onkeyup="showUser(this.value);"/>
</form>

</div>
<div id="get">

</div>
<div id="time">
<script type="text/javascript">
show();
</script>

</div>
</body>
</html>

 

On the left side of the page at the very top in the input id it shows keyword and then a text box. Then on the left it shows the time. The problem is that even though it shows the time on the left it is not where I want it. I want it to be on the same line as the keyword and text box but it is about 3 lines down. Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/126767-solved-why-oh-why-css/
Share on other sites

Yeah it was confusing me as well. I have tried several things and nothing seems to fix this issue. Does anyone have any other suggestions? By the way thanks for your help f1fan. If someone might have some spare time and want to copy the pages and try to get them to display correctly it would be appreciated. Maybe I can help with something else

Ah hah! I think I figured it out. I just copied your code to one of my sites and tested it. It wasn't displaying properly at first. Then I added display: inline; to the form tag and it worked. This is my exact code (changed a little, because I don't have your js file):

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<style type="text/css">
body {
margin:0 auto;
width:800px;
height:100%;
border:1px solid #000000;
}
#input {
display: inline;
}
#get {
display: inline;
}
#time {
display: inline;
}
</style>
</head>

<body>

<div id="input">
<form name="form1" style="display:inline;">
Keyword:
<input type="text" name="keyword"/>
</form>

</div>
<div id="get">
get
</div>
<div id="time">
time
</div>
</body>
</html>

Try this for your CSS:

body {
position: relative;
top: 0px;
left: 0px;
margin:0 auto;
width:800px;
height:100%;
border:1px solid #000000;
}
#input {
display: inline;
}
#get {
display: inline;
}
#time {
position: absolute;
top: 0px;
right: 0px;
display: inline;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.