DIVS move according to browser size

Asked

Viewed 243 times

0

As Divs move as browser size changes.

When I change the browser size.

body
{
	margin: 0; 
	background: #FFF;
}

/*CLASSES UTEIS*/
.foco:focus
{
	outline: none;
}

/*CABEÇARIO*/
#cabecario
{
	width: auto;
	height: 40px;
	background: #7bdac1;
}
#logo_div
{
	float: left;
	width: 141px;
	height: 40px;
	margin-left: 30px;
	position: relative;
}
#logo
{
	margin-top: 3px;
}
#search_div
{
	float: left;
	width: 300px;
	height: 40px;
	margin-left: 70px;
	position: relative;
}
#search_bar
{
	width: 300px;
	height: 26px;
	margin-top: 6px;
}
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LuppBox</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</head>
<body>
	<header>
		<div id="cabecario" name="cabecario">
			<div id="logo_div" name="logo_div">
				<img src="http://i.stack.imgur.com/jBNwP.jpg" id="logo" name="logo" width="auto" height="35">
			</div>
			<div id="search_div" name="search_div">
				<input id="search_bar" name="search_bar" type="search" class="foco">
			</div>
		</div>
	</header>
</body>
</html>

  • Please provide an example of the problem that can be reproduced.

  • I put in question the HTML and CSS I am using.

  • Luke they can not be reproduced as in the image, please post an example of the problem that can be reproduced, help us to help you. Grateful

  • Arranged, can be executed now.

1 answer

1


The problem is here:

#cabecario
    {
        width: auto;
        height: 40px;
        background: #7bdac1;
    }

Place a specific width instead of automatic, like:

width: 1000px;

Updating:

Put it this way you’ll understand:

#cabecario
        {
            min-width: 600px;
            height: 40px;
            background: #7bdac1;
        }

This way when reducing the size of the browser it will not let the Divs move, because you have set a minimum size. It will always display the Divs in the size needed to not distort.

I put 600px in the example, but you can test smaller values like 500px and see how far you won’t move the Divs.

  • How should I proceed to get the screen size of who is accessing ??

  • You need it to appear at 100%, right? Set a minimum size then. Check the width of the Ivs and set it to the minimum width: min-width: 600px for example.

  • Could give an executable example in your reply ??

  • I updated the answer. Check and tell me

  • It worked well, vlw.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.