我正在寻找一种使用引导标签的方法,如下所示:
我有一张桌子,我希望每一个都被点击一行,它会显示一张图片。
这可以实现吗?
引导代码如下,但我想将链接应用到一行''
DIV>
typedef struct http_request {
http_request *next;
int conn_fd; // fd to talk with client
int status; // not used, error, reading (from client), writing (to client)
char file[MAXBUFSIZE]; // requested file
char query[MAXBUFSIZE]; // requested query
char host[MAXBUFSIZE]; // client host
char* buf; // data sent by/to client
size_t buf_len; // bytes used by buf
size_t buf_size; // bytes allocated for buf
size_t buf_idx; // offset for reading and writing
} http_request;
http_request *requests_head = NULL;
http_request *requests_tail = NULL;
while (1) { /* Main loop */
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
FD_SET(server.listen_fd, &read_fds);
int maxfd = server.listen_fd;
http_request *request = requests_head;
while (request) {
FD_SET(request->conn_fd, &read_fds);
if (request->status == WRITING} {
FD_SET(request->conn_fd, &write_fds);
}
maxfd = max(request->conn_fd, maxfd);
request = request->next;
}
if (select(maxfd+1, &read_fds, &write_fds, NULL, NULL) < 0)
ERR_EXIT("select")
printf("server select() is OK!\n");
if (FD_ISSET(server.listen_fd, &read_fds)) {
clilen = sizeof(cliaddr);
conn_fd = accept(server.listen_fd, (struct sockaddr *) &cliaddr, (socklen_t *) &clilen);
if (conn_fd < 0) {
if ((errno != EINTR) && (errno != EAGAIN)) { // try again later
if (errno != ENFILE) {
ERR_EXIT("accept")
}
fprintf(stderr, "out of file descriptor table ... (maxconn %d)\n", maxfd);
}
}
else
{
request = (http_request*) malloc(sizeof(http_request));
if (!request) {
// error handling ...
close(conn_fd);
}
else
{
memset(request, 0, sizeof(http_request));
request->conn_fd = conn_fd;
request->status = READING;
strcpy(request->host, inet_ntoa(cliaddr.sin_addr));
set_ndelay(conn_fd);
fprintf(stderr, "getting a new request... fd %d from %s\n", conn_fd, request->host);
if (!requests_head) requests_head = request;
if (requests_tail) requests_tail->next = request;
requests_tail = request;
}
}
}
request = requests_head;
http_request *next, *prev = NULL;
while (request) {
if (FD_ISSET(request->conn_fd, &read_fds)) {
// Handle data from a client
if (request->state != READING) {
char recv[1024];
if (read(request->conn_fd, recv, sizeof(recv)) <= 0) {
fprintf(stderr, "error on fd %d, code %d\n", request->conn_fd, err);
close(request->conn_fd);
free_request(request);
next = request->next;
if (request == requests_head) requests_head = next;
if (request == requests_tail) requests_tail = prev;
if (prev) prev->next = next;
free(request);
request = next;
continue;
}
}
else
{
fprintf(stderr, "reading from conn_fd %d\n", request->conn_fd);
ret = read_header_and_file(request, &err);
if (ret < 0) {
fprintf(stderr, "error on fd %d, code %d\n", request->conn_fd, err);
close(request->conn_fd);
free_request(request);
next = request->next;
if (request == requests_head) requests_head = next;
if (request == requests_tail) requests_tail = prev;
if (prev) prev->next = next;
free(request);
request = next;
continue;
}
if (ret == 0) {
request->status = WRITING;
FD_SET(request->conn_fd, &write_fds);
}
}
}
if (FD_ISSET(request->conn_fd, &write_fds)) {
// Handle data to a client
if (request->buf_idx < request->buf_len) {
fprintf(stderr, "writing (buf %s, idx %d) %d bytes to request fd %d\n", request->buf, (int) request->buf_idx, (int) request->buf_len, request->conn_fd);
nwritten = write(request->conn_fd, &request->buf[request->buf_idx], request->buf_len - request->buf_idx);
if (nwritten < 0) {
if ((errno != EINTR) && (errno != EAGAIN)) {
fprintf(stderr, "error on fd %d, code %d\n", request->conn_fd, errno);
close(request->conn_fd);
free_request(request);
next = request->next;
if (request == requests_head) requests_head = next;
if (request == requests_tail) requests_tail = prev;
if (prev) prev->next = next;
free(request);
request = next;
continue;
}
}
else
{
request->buf_idx += nwritten;
}
}
if (request->buf_idx == request->buf_len) {
fprintf(stderr, "complete writing %d bytes on fd %d\n", (int) request->buf_len, request->conn_fd);
fprintf(stderr, "=============================================\n");
int fd[2];
if (pipe(fd) == -1)
ERR_EXIT("pipe")
pid_t pid;
if ((pid = fork()) < 0)
ERR_EXIT("fork")
else if (pid == 0) { /* In Child Process */
close(fd[0]);
dup2(fd[1], STDOUT_FILENO);
close(fd[1]);
execl("file_reader", "./file_reader", request->query, (char *)0);
fprintf(stderr, "Error: Unexpect flow of control.\n");
exit(EXIT_FAILURE);
}
else { /* In Parent Process */
close(fd[1]);
char recv[1024];
read(fd[0], recv, sizeof(recv));
printf("The file content is:\n%s\n", recv);
}
close(request->conn_fd);
free_request(request);
next = request->next;
if (request == requests_head) requests_head = next;
if (request == requests_tail) requests_tail = prev;
if (prev) prev->next = next;
free(request);
request = next;
continue;
}
}
request = request->next;
}
}
我想避免在td中使用它:
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
<li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">SHOW IMAGE 1</div>
<div role="tabpanel" class="tab-pane" id="profile">SHOW IMAGE 2</div>
<div role="tabpanel" class="tab-pane" id="messages">SHOW IMAGE 3</div>
<div role="tabpanel" class="tab-pane" id="settings">SHOW IMAGE 4</div>
</div>
因为点击区域只是文本而我希望它是行
我希望你能帮助我
答案 0 :(得分:0)
抱歉,我在code snippet中没有看到任何TABLE。当用户点击tr。
时,不太确定如何弹出图像您可能对手风琴感兴趣。这是你的fiddle:
<button class="accordion">Home</button>
<div class="panel">
<img>
</div>
<button class="accordion">Profile</button>
<div class="panel">
<img>
</div>