我想在页面左侧有一个容器(带有一些文本),它可以根据可用空间进行调整,右侧有 2 个侧边栏(我正在使用 Wordpress)。(2 个侧边栏与float.配合良好。)所以我尝试width:auto了容器。
但它不会适应剩余的可用空间(它占用所有页面宽度)。如果我将宽度设置为70%,它适合索引页上的空间,但如果我点击一篇文章,我只剩下 1 个侧边栏,所以文本和侧边栏之间有一个空白空间。
你知道如何解决这个问题吗?
#container { /* the text */
overflow:auto;
width:auto;
position:relative;
float:left;
}
#primary { /* first sidebar */
position:relative;
border:1px solid red;
float:right;
width:250px;
}
#second { /* second sidebar */
border:1px solid red;
background:white;
width:250px;
height:auto;
float:right;
margin-left:15px;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
编辑 :
假设我正在使用它而不是 wordpress 侧边栏:我仍然无法使其工作,有人可以看看这个简单的代码吗?有两个盒子:绿色一个和红色一个...
<!DOCTYPE>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<div style="position:relative; width:700px; margin:0 auto;">
<div style="width:auto; border:1px …Run Code Online (Sandbox Code Playgroud) 我有一个DIV(设置为float:left),它的宽度设置为auto因为我希望它和它的内容一样宽。
在悬停,我想增加宽度的的DIV的说,20个像素。
在:hover CSS 类中设置固定宽度时,容器将在悬停时获得该宽度,但是
如何 - 在不使用 javascript 的情况下 - 我可以将DIV的内容调整为其内容,并在悬停时将宽度增加一定数量的像素吗?
这是我用来生成视图对象的代码:
// creates the seekBar
sBGauge = new SeekBar(this);
sBGauge.setMax(depthL - 1);
sBGauge.setMinimumWidth(150);
sBGauge.setId(2000 + i);
sBGauge.setOnSeekBarChangeListener(this);
Run Code Online (Sandbox Code Playgroud)
我设置了 sBGauge.setMinimumWidth(); 它似乎总是只有大约 20 宽。
有什么想法吗?谢谢
编辑:为了提供更多信息,我在 tablerow 中的两个 textViews 之间使用此搜索栏。
撞
该网页是站点链接。如果减小窗口大小,透明灰色background消失。我已经尝试了很多方法来解决这个问题,但没有成功。有任何想法吗?我使用的 CSS 是:
#content {
margin-bottom: 20px;
padding-left: 20px;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.6);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";
overflow:auto;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个(1 行,3 列)条形图数组,它们都具有相同的条形宽度。
所有三个条形图都有不同数量的观测值,因此每个图的条形宽度最终都不同(即,具有最多观测值的图形具有最窄的条形,而具有最少观测值的图形具有最宽的条形)。我从barplot {graphics} R文档中了解到,
“除非
xlim指定,否则指定单个值将没有可见效果”
但是,我x labels是字符串,所以我不确定如何指定xlim. 我不介意我的图的宽度是否不同,但是我需要以某种方式指定它吗?
这是一些假数据和我正在使用的代码……谢谢你的帮助。
height4plot1 <- c(1,6,9,2,3,10,7,15)
names4plot1 <- c("P1","P2","P3","P4","P5","P6","P7","P8")
height4plot2 <- c(5,4,10,2)
names4plot2 <- c("M1","M2","M3","M4")
height4plot3 <- c(4,12)
names4plot3 <0 c("U1","U2")
par(mfrow=c(1,3),
mar=c(10,5,2,1),
cex.axis=0.7,
mgp=c(3,0.5,0))
barplot(height4plot1,
names.arg=names4plot1,
las=3,
axes=TRUE,
axisnames=TRUE,
ylab="YLAB",
ylim=ylim,
plot=TRUE,
main="PLOT1",
width=1)
barplot(height4plot2,
names.arg=names4plot2,
las=3,
axes=TRUE,
axisnames=TRUE,
ylim=ylim,
plot=TRUE,
main="PLOT2",
width=1)
barplot(height4plot3,
names.arg=names4plot3,
las=3,
axes=TRUE,
axisnames=TRUE,
ylim=ylim,
plot=TRUE,
main="PLOT3",
width=1)
Run Code Online (Sandbox Code Playgroud) 对某人来说应该是一个很好的简单的...
我有一个面板,我正在向其中动态添加子控件,当它们中的任何一个放置在可见区域之外时,滚动条将出现。
我需要知道这个区域的总面积。即可滚动区域有多宽?
我可以获得最远放置的控件并使用其 left + width 属性,但必须有更简洁的方法吗?
编辑:希望这说明我需要什么(可滚动区域宽度)。

我在表中使用表。我希望子表填充父表单元格。这可能吗?
此外,表列是否有可能在不缩小其他列的情况下填充剩余空间(不像width='90%'这可能会迫使其他一些列被截断)?
I am trying to solve the problem of using Javascript to determine the width of my browser's "window". I'm aware different people can mean different things in this context so to be specific I mean the area in green as in this post.
I've read the first two replies to that post and a number of other stackoverflow solutions to this problem, none of which I could get to work: I am using Firefox 27.0.1 with the window maximised on …
我无法获得ActualWidth任何非零值的画布。我简化了真实场景,并在 VS 中使用了一个新的 WPF 应用程序来获取非零值(和理解)。不幸的是,我只得到零。我觉得我缺少一些基本的 WPF 理解:我对 WPF 不太熟悉。
我复制了MDSN 演示,稍微修改了一下,现在我有了
public partial class MainWindow : Window {
private Canvas myCanvas;
public MainWindow()
{
InitializeComponent();
CreateAndShowMainWindow();
}
private void CreateAndShowMainWindow()
{
// Create a canvas sized to fill the window
myCanvas = new Canvas();
myCanvas.Background = Brushes.LightSteelBlue;
// Add a "Hello World!" text element to the Canvas
TextBlock txt1 = new TextBlock();
txt1.FontSize = 14;
txt1.Text = "Hello World!";
Canvas.SetTop(txt1, 100);
Canvas.SetLeft(txt1, 10);
myCanvas.Children.Add(txt1);
// Add …Run Code Online (Sandbox Code Playgroud) 如何使单个按钮宽度以编程方式填充父级?我已经这样做了,但它似乎无法工作它仍然位于左上角,宽度只是包装内容......这里是按钮创建的一些代码......
public class TEST_GIFDisplay extends Activity implements View.OnClickListener {
SurfaceView sview;
GifRun gr = new GifRun();
Button btnBack;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sview = new SurfaceView(this);
sview.setZOrderOnTop(true);
gr.LoadGiff(sview, this, R.drawable.smiley);
LinearLayout linearLayout1 = new LinearLayout(this);
linearLayout1.setOrientation(LinearLayout.VERTICAL);
linearLayout1.setBackgroundColor(Color.parseColor("#27ae60"));
linearLayout1.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
LinearLayout linearLayout2 = new LinearLayout(this);
linearLayout2.setOrientation(LinearLayout.VERTICAL);
linearLayout2.setBackgroundColor(Color.parseColor("#27ae60"));
linearLayout2.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams p = new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
p.weight = 1.0f;
btnBack = new Button (this);
btnBack.setText("Back");
btnBack.setBackgroundColor(Color.parseColor("#f1c40f"));
btnBack.setGravity(Gravity.CENTER_HORIZONTAL);
btnBack.setLayoutParams(p);
btnBack.setOnClickListener(this);
linearLayout2.addView(btnBack);
linearLayout1.addView(linearLayout2);
linearLayout1.addView(sview);
setContentView(linearLayout1);
}
@Override
public …Run Code Online (Sandbox Code Playgroud) width ×10
css ×5
html ×3
android ×2
c# ×2
actualwidth ×1
area ×1
background ×1
button ×1
css-float ×1
css-tables ×1
fill ×1
formatting ×1
javascript ×1
panel ×1
parent ×1
plot ×1
r ×1
seekbar ×1
transitions ×1
viewport ×1
wpf ×1
wpf-controls ×1